You can use named routes.
return redirect()->route('routeName');
Name your route accordingly.
https://laravel.com/docs/7.x/routing#named-routes
Or you can simply do the following:
return redirect('/boilerplate');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am in a Boilerplate model update method (entered via a PATCH request to the 'boilerplate.update' route).
<form action="{{ route('boilerplate.update',['id'=>$bp->id]) }}" method="POST">
{{-- Patching Objectives; this could include adding some... --}}
@method('PATCH')
@csrf
Routes are defined with:
Route::resource('/boilerplate', 'BoilerplateController')->middleware('auth');
| | POST | boilerplate | boilerplate.store | App\Http\Controllers\BoilerplateController@store | web,auth |
| | GET|HEAD | boilerplate | boilerplate.index | App\Http\Controllers\BoilerplateController@index | web,auth |
| | GET|HEAD | boilerplate/create | boilerplate.create | App\Http\Controllers\BoilerplateController@create | web,auth |
| | DELETE | boilerplate/{boilerplate} | boilerplate.destroy | App\Http\Controllers\BoilerplateController@destroy | web,auth |
| | PUT|PATCH | boilerplate/{boilerplate} | boilerplate.update | App\Http\Controllers\BoilerplateController@update | web,auth |
| | GET|HEAD | boilerplate/{boilerplate} | boilerplate.show | App\Http\Controllers\BoilerplateController@show | web,auth |
| | GET|HEAD | boilerplate/{boilerplate}/edit | boilerplate.edit | App\Http\Controllers\BoilerplateController@edit | web,auth |
After successfully updating the model, I just:
$boilerplate->update(['title' => Str::title($request->title), 'content' => $request->content]);
return view('boilerplate.index');
This is working with the index view displayed, but the URL displayed in the browser is of the "show" form
https://mydomain.com/boilerplate/nn
rather than the expected
https://mydomain.com/boilerplate
Can anyone help me understand why this is happening?
You can use named routes.
return redirect()->route('routeName');
Name your route accordingly.
https://laravel.com/docs/7.x/routing#named-routes
Or you can simply do the following:
return redirect('/boilerplate');
Please or to participate in this conversation.