【发布时间】:2021-10-19 23:46:48
【问题描述】:
我为web.php使用了以下代码。
Route::resource('products', 'ProductController');
Route::resource('products.galleries', 'GalleryController');
在这个地址 http://localhost:8000/admin/products ,我加了这段代码
<td><a href="{{ route('products.galleries.create', $product->id) }}">Create</a></td>
然后我在create方法中定义它,并控制GalleryController
GalleryController.php
public function create(Product $product)
{
return view('Admin.galleries.create', compact('product'));
}
画廊是空的
我正在使用 下拉菜单
$.ajax({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
},
type: 'POST',
url: '{{ route('products.galleries.destroy', [$product->id, $gallery->id]) }}',
date: {filename, name},
success: function (data) {
console.log('File has been successfully removed!!');
},
error: function (e){
console.log(e);
},
});
我收到此错误
未定义变量:图库
谁能告诉我如何解决这个问题?
【问题讨论】: