PATH:
home
/
rwabteecom
/
project_11
/
app
/
Http
/
Controllers
/
Dashboard
/
Profile
/
Editing: ProfileController.php
<?php namespace App\Http\Controllers\Dashboard\Profile; use App\Http\Controllers\Controller; use App\Models\User; use App\Services\Profile\ProfileServices; use Illuminate\Http\Request; use App\Services\Socials\SocialServices; use Exception; use Log; use Auth; use Illuminate\Validation\Rule; class ProfileController extends Controller { public function __construct( private readonly ProfileServices $profileServices, ) { } public function index() { return view('dashboard.pages.profile')->with([ 'user' => Auth::user(), ]); } public function updateProfileImage(Request $request) { try { $user = auth()->user(); $this->profileServices->updateProfileImage($request); } catch (Exception $exception) { Log::error($exception->getMessage()); return $this->sendFailedResponse($exception->getMessage()); } $user = User::query()->findOrFail(auth()->user()->id); return $this->sendSuccessResponse(['profileImage' => $user->profileImage], __('Image Updated successfully')); } public function updateUserData(Request $request) { try { $request->validate([ 'email' => [ 'required', 'string', 'email:rfc,dns', Rule::unique('users', 'email')->ignore(auth()->user()->id), ], "name" => "required|string", ]); $this->profileServices->updateUserData($request); } catch (Exception $exception) { Log::error($exception->getMessage()); return $this->sendFailedResponse($exception->getMessage()); } return $this->sendSuccessResponse(['success' => __('Profile Updated Successfully')]); } public function updatePassword(Request $request) { try { $request->validate([ "current_password" => "required|min:6", "password" => "required|confirmed|min:6", ]); $this->profileServices->updatePassword($request); } catch (Exception $exception) { Log::error($exception->getMessage()); return $this->sendFailedResponse($exception->getMessage()); } return $this->sendSuccessResponse(['success' => __('Passwrod Updated Successfully')]); } }
SAVE
CANCEL