All routes related to Authentication are placed in
routes/auth.php file, which is loaded inside routes/api.php.Registration
For registration in Larafast API Boilerplate responsibleapp/Http/Controllers/Auth/RegisteredUserController.php.
The store method is the primary method in this controller. It handles incoming registration requests. The method accepts a RegisterRequest object, which encapsulates the validation rules for the registration data.
Here’s a brief overview of the store method:
store method performs the following steps:
-
It creates a new
Userinstance using the validated data from theRegisterRequestobject. The password is hashed before being stored in the database. -
It fires a
Registeredevent, passing the newly created user as the event’s argument. This event can be used to perform actions after a user has been registered, such as sending a welcome email. - If roles are implemented in the application, a role can be assigned to the user at this point. This line is commented out in the provided code.
- Finally, it returns a JSON response containing a token for the newly registered user. This token can be used for subsequent authenticated requests.
To learn more about the
return response()->token($user); method, refer to the Response Macros section.Reference in Postman: Register

