user(); $user->forceFill(['password' => Hash::make($request->validated('password'))])->save(); $current = $user->currentAccessToken(); $currentId = $current instanceof PersonalAccessToken ? $current->id : null; PersonalAccessToken::query() ->where('tokenable_type', $user->getMorphClass()) ->where('tokenable_id', $user->id) ->when($currentId, fn ($q, $id) => $q->where('id', '!=', $id)) ->delete(); return $this->ok([ 'password_changed' => true, 'other_sessions_revoked' => true, ], 'Password changed'); } }