получение страницы не найдено при отправке в laravel 5.6 - PullRequest
0 голосов
/ 27 марта 2019

У меня есть проект laravel, где при отправке формы я не могу найти страницу ошибки, в то время как я создал маршрут и все

маршруты:

Route::get('/', 'IndexController@index');

Route::post('/remove/{product}', 'ProductController@removeProduct')->name('remove');

Route::group(['as' => 'cart.', 'prefix' => 'cart'], function () {

    Route::post('/update/{product}', 'ProductController@updateProduct')->name('update');
});
Route::get('cart', 'ProductController@cart')->name('all');
Route::get('/{type}', 'IndexController@loadview');

Просмотр файла:

<form action="{{route('remove', $slug)}}" method="POST" accept-charset="utf-8">
                            @csrf

                            <input type="submit" name="remove" value="x Remove" class="btn btn-danger"/>
                            </form>

ProductController:

   public function removeProduct(Product $product){
    return 'something';
      $oldCart = Session::has('cart') ? Session::get('cart') : null;
      $cart = new Cart($oldCart);
      $cart->removeProduct($product);
      Session::put('cart', $cart);
      return back()->with('message', "Product $product->title has been successfully removed From the Cart");
   }

1 Ответ

0 голосов
/ 27 марта 2019

удалить Product из removeProduct(Product $product) как в вашем маршруте только что сделал его переменным

Route::post('/remove/{product}', 'ProductController@removeProduct')->name('remove');

но если вы хотите использовать это removeProduct(Product $product), то

используйте маршрутизацию ресурсов для более подробной информации, обновляя тот же клик здесь

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...