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:
-
Open your Terminal window and type the following command:
php artisan make:controller API/AuthController
- 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. ...