Я хочу удалить элемент, но я получил это сообщение об ошибке:
(1/1) MethodNotAllowedHttpException
in RouteCollection.php line 255
at RouteCollection->methodNotAllowed(array('PUT', 'DELETE'))
мои маршруты:
Route::group(['prefix' => '/Seller', 'middleware' => ['seller_access']], function () {
Route::get('/','Seller\SellerController@index')->name('seller');
Route::group(['prefix' => '/Products'], function () {
Route::get('/', 'MarketingBundle\Seller\Product\ProductController@index')->name('marketing.seller.product.index');
Route::delete('/{id}', 'MarketingBundle\Seller\Product\ProductController@delete')->name('marketing.seller.product.delete');
Route::put('/{id}', 'MarketingBundle\Seller\Product\ProductController@update')->name('marketing.seller.product.update');
});
мой URL:
Seller/Products/228
мойконтроллер:
class ProductController extends Controller
{
public $resources = "marketing.seller.product";
public function index(Request $request)
{
$products = \Auth::user()->sellerProduct()->paginate(10);
return view($this->resources . '.index', [
'products' => $products
]);
}
/**
* @param $product_id
* @return \Illuminate\Http\JsonResponse
*/
public function delete($product_id)
{
dd("masoud");
\Auth::user()->sellerProduct()->detach(['product_id' => $product_id]);
return response()->json(['status' => true]);
}