Reputation: 6740
I want to make a settings screen for my users, and I want the URL to be easy an memorable: domain.com/user/settings
I want this route to point use the UserController@edit
method, however, the edit()
method requires ID parameter.
Is there someway I can use user/settings
URL without specifying the ID in the URL, but still use the same edit()
method in the UserController
?
Upvotes: 0
Views: 773
Reputation: 5609
The edit URL could be use without any parameter. In that case you can mention the user in controller.
Route
Route::get('user/settings');
Controller
public function edit()
{
$user = Auth::user();
}
Upvotes: 1
Reputation: 6740
Seems like I managed to solve it?
web.php
:
Route::get('user/settings', 'UserController@edit')->name('user.settings');
Route::resource('user', 'UserController');
UserController.php
:
public function edit(User $user = null)
{
$user = Auth::user();
}
Upvotes: 0