[英]Laravel Redirecting to a route is not working?
I am new to Laravel, when I am using redirect()->route('route_name') after saving data, it does not work.我是 Laravel 的新手,当我在保存数据后使用 redirect()->route('route_name') 时,它不起作用。
Here is my controller function:这是我的 controller function:
public function store_layouts(Request $data){
$layout = new point_prizes();
$layout->name = $data->name;
$layout->points = $data->points;
$layout->prize = $data->price;
$layout->timestamps = false;
$layout->save();
redirect()->route('view_layouts');
}
Here are my routes:这是我的路线:
Route::get('/admin/layouts' , 'AdminController@view_layouts')->name('view_layouts');
Route::get('/admin/layouts/make' , 'AdminController@create_layouts')->name('create_layouts');
Route::post('/admin/layouts/store' , 'AdminController@store_layouts')->name('store_layouts');
Any help will be appreciated.任何帮助将不胜感激。
You need to add the return
keyword您需要添加
return
关键字
return redirect()->route('view_layouts');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.