User Password Controller

For understanding, how the controller code, please refer to company controller

php artisan make:controller Auth\\UserPasswordController

Replace the code with below

Note: Please use the copy button to copy the source code.

We need to include the following import statement(s)
use Illuminate\Support\Facades\Hash;
use App\Models\User;
use App\Models\Company;

class UserPasswordController extends Controller { public function __construct() { $this->middleware('auth'); } public function show($id) { $this->authorize('read', User::class); session(['pageTitle' => 'User Account: Change Password']); session(['pageTitleIcon' => 'fa fa-pencil']); $user = User::find($id); return view('auth.passwords.change', [ 'user'=> $user, ]); } public function update(Request $request,$id) { $this->authorize('change_password', User::class); $request->validate([ 'password' => 'required|min:8|confirmed', ]); $user = User::find($id); $user->password = Hash::make($request->password); $user->save(); return back()->with('success', trans('message.update_password_success')); } }