Fetching Authenticated User
Theshow
method in the AuhUserController
class is used to fetch the authenticated user. It returns a UserResource
instance for the authenticated user.
Updating Authenticated User
Theupdate
method in the AuhUserController
class is used to update the authenticated user’s details. It accepts an UpdateUserRequest
instance which validates the incoming request data. The rules
method of this class specifies that the name
, email
, and password
fields are optional, but if provided, they must meet certain criteria.
Deleting Authenticated User
Thedestroy
method in the AuhUserController
class is used to delete the authenticated user. It deletes the authenticated user from the database and returns a success message.
Routes
The routes for fetching, updating, and deleting the authenticated user are defined in theroutes/auth.php
file. All these routes use the AuhUserController
class, and the show
, update
, and destroy
methods respectively. These routes are grouped under a middleware that ensures only authenticated users can access them.