Laravel添加输入表单后,我看到的是一个空白页,而不是视图
我尝试创建一个购物车并传递数据,所以我在我的产品页面上做了一个按钮“添加到购物车”,在我按下按钮后,我确实被重定向到/cart,但我得到了一个空白页面而不是视图Laravel添加输入表单后,我看到的是一个空白页,而不是视图,laravel,Laravel,我尝试创建一个购物车并传递数据,所以我在我的产品页面上做了一个按钮“添加到购物车”,在我按下按钮后,我确实被重定向到/cart,但我得到了一个空白页面而不是视图 {{ Form::open(['route' => ['cart.store'],'method' =>'POST']) }} {{ Form::submit('Pridať do košíka', ['class' => 'btn btn-success', 'style' => 'margin
{{ 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']);
我在没有表单助手的情况下尝试了同样的方法,结果是一样的
我使用的是Laravel5.7,我使用的是laravelshoppingcart扩展
我被难住了,所以提前谢谢你的帮助。日志中有什么内容吗?你也可以发布你的路线文件吗?@KST我添加了路线文件,我在哪里可以找到日志?我没有得到任何错误时,查看网页,只有一个空白页,你也可以显示的内容CartController@index? 编辑:没关系,我看到了。查看购物车索引如何?日志通常在
storage/logs
@KST cart.index只是html和css,我实际上在日志文件[2020-01-08 23:18:54]local.ERROR:Class'App\Http\Controllers\cart'not found{“exception”:“[object](Symfony\\Component\\Debug\\exception\\FatalThrowableError(代码:0):类“App\\Http\\Controllers\\Cart”在C:\\xampp\\code\\eeshoptest\\App\\Http\\Controllers\\CartController.php:39中找不到,我将更仔细地查看它。我的日志文件非常大(3MB),所以我不知道真正要查找什么,我还假设我必须在控制器中为上述错误命名Cart,尽管这并没有解决我的问题。