diff --git a/app/Http/Controllers/Auth/ProfileController.php b/app/Http/Controllers/Auth/ProfileController.php new file mode 100644 index 0000000..e6e6ae1 --- /dev/null +++ b/app/Http/Controllers/Auth/ProfileController.php @@ -0,0 +1,37 @@ +middleware('auth'); + } + + public function show() + { + return view('auth.profile', ['user' => auth()->user()]); + } + + public function update(Request $request) + { + $profileData = $request->validate([ + 'name' => 'required|max:60', + 'email' => 'required|email', + ]); + + $user = auth()->user(); + + $user->name = $profileData['name']; + $user->email = $profileData['email']; + $user->save(); + + flash()->success(trans('auth.profile_updated')); + return back(); + } + +} diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index e2770f7..0df3ade 100755 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -70,27 +70,4 @@ class AuthController extends Controller flash()->success(trans('auth.welcome', ['name' => $user->name])); return redirect()->route('home'); } - - public function getProfile() - { - $user = Auth::user(); - return view('auth.profile', compact('user')); - } - - public function patchProfile(Request $request) - { - $profileData = $request->validate([ - 'name' => 'required|max:60', - 'email' => 'required|email', - ]); - - $user = auth()->user(); - - $user->name = $profileData['name']; - $user->email = $profileData['email']; - $user->save(); - - flash()->success(trans('auth.profile_updated')); - return back(); - } } diff --git a/routes/web/account.php b/routes/web/account.php index a66b125..2496f3b 100644 --- a/routes/web/account.php +++ b/routes/web/account.php @@ -8,11 +8,12 @@ Route::group(['middleware' => 'web','as'=>'auth.'], function() { Route::get('logout', ['as'=>'logout', 'uses' => 'AuthController@getLogout']); Route::get('register', ['as'=>'register', 'uses' => 'AuthController@getRegister']); Route::post('register', ['as'=>'register', 'uses' => 'AuthController@postRegister']); - Route::get('activate', ['as'=>'activate', 'uses' => 'AuthController@getActivate']); - Route::get('profile', ['as'=>'profile', 'uses' => 'AuthController@getProfile']); - Route::patch('profile', ['as'=>'profile', 'uses' => 'AuthController@patchProfile']); }); +// User Profile Routes... +Route::get('profile', ['uses' => 'Auth\ProfileController@show'])->name('auth.profile'); +Route::patch('profile', ['uses' => 'Auth\ProfileController@update'])->name('auth.profile'); + // Change Password Routes... Route::get('change-password', 'Auth\ChangePasswordController@show')->name('auth.change-password'); Route::patch('change-password', 'Auth\ChangePasswordController@update')->name('auth.change-password');