简体   繁体   中英

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.

Here is my 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 redirect()->route('view_layouts');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM