Authenticating users
Allowing users to register and sign in is an extremely common feature in web applications. Yet, PHP does not dictate how it should be done, nor does it give you any helpers to implement it. This has led to the creation of disparate, and sometimes insecure, methods of authenticating users and restricting access to specific pages. In that respect, Laravel provides you with different tools to make these features more secure and easier to integrate. It does so with the help of its authentication service and functionality that we have not covered yet—middleware.
Creating the user model
First of all, we need to define the model that will be used to represent the users of our application. Laravel already provides you with sensible defaults inside config/auth.php
, where you can change the model or table that is used to store your user accounts.
It also comes with an existing User
model inside app/User.php
. For the purposes of this application, we are going to simplify it slightly...