Creating the authController

For our application, we will use only one controller to contain all our operations of registration and login, which are register, login, and logout.

Later in this book, you will understand why we are using all operations within a single controller instead of creating a controller for each action:

  1. Open your Terminal window and type the following command:

php artisan make:controller API/AuthController
  1. Open project/app/Http/Controllers/API/AuthController.php and replace its content with the following code:
 <?php namespace App\Http\Controllers\API; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\User; use Validator; class AuthController extends Controller { /** * Register a new user. ...

Get Hands-On Full Stack Web Development with Angular 6 and Laravel 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.