Laravel после добавления формы ввода вместо просмотра отображается пустая страница - PullRequest
0 голосов
/ 07 января 2020

Я попытался создать корзину для покупок и передать данные, поэтому я сделал кнопку «добавить в корзину» на странице своего продукта, после нажатия кнопки меня перенаправили в / корзину, но вместо пустой страницы я получил представление

{{ Form::open(['route' => ['cart.store'],'method' =>'POST']) }}
        {{ Form::submit('Pridať do košíka', ['class' => 'btn btn-success', 'style' => 'margin-top:15px;']) }}
    {{ Form::close() }}

Кроме того, после добавления ввода, чтобы я мог передать данные в кнопке, даже страница продукта стала пустой!

{{ Form::hidden(['title','{{$post->title }}'])}}

это мой контроллер

  public function index()
    {
        return view('cart.index');
    }

public function store(Request $request)
    {
   Cart::add($post, 1)->associate('App\Post');

        Session::flash('Úspech', 'Úspešne ste pridali produkt do košíka');

        return redirect()->route('cart.index');
    }

мой маршрут

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


Route::get('/home', 'HomeController@index')->name('home');

Auth::routes(['verify' => true]);

Route::get('profile', function () {
    return 'This is profile';
})->middleware('verified');

Route::get('/obchod', 'PagesController@getObchod');

Route::get('/product', 'PagesController@getProduct');

Route::get('/blogtest', 'PagesController@getBlogtest');

Route::get('/kontakt', 'PagesController@getKontakt');


Route::resource('cart', 'CartController'); 

Route::prefix('admin')->group(function(){

Route::get('/login', 'Auth\AdminLoginController@showLoginForm')->name('admin.login'); 
Route::post('/login', 'Auth\AdminLoginController@login')->name('admin.login.submit'); 
Route::get('/', 'AdminController@index')->name('admin.dashboard');
});
//produkty
Route::resource('posts','PostController');  
//kategorie
Route::resource('categories','CategoryController', ['except' => ['create']]);
//pouzivatelia
Route::resource('users','UserController');
//komentare
Route::post('comments/{post_id}', ['uses' => 'CommentsController@store', 'as' => 'comments.store']);
Route::get('comments/{id}/edit', ['uses' => 'CommentsController@edit', 'as' => 'comments.edit']);
Route::put('comments/{id}', ['uses' => 'CommentsController@update', 'as' => 'comments.update']);
Route::delete('comments/{id}', ['uses' => 'CommentsController@destroy', 'as' => 'comments.destroy']);
Route::get('comments/{id}/delete', ['uses' => 'CommentsController@delete', 'as' => 'comments.delete']);




Route::get ('shop/{slug}', ['as' => 'shop.single', 'uses' => 'ShopController@getSingle'])->where('slug','[\w\d\-\_]+');
Route::get('shop', ['uses' => 'ShopController@getIndex', 'as' => 'shop.index']);

Я пробовал то же самое без помощников формы, результат был тот же.

Я на laravel 5.7, и я использую расширение laravelshoppingcart.

Я довольно озадачен, поэтому заранее спасибо за помощь.

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