Laravel Framework

Laravel comes with built in authentication to enable it first create the users table by running the default migrations:

php artisan migrate

Next create the authentication:

php artisan make:auth

Once run auth views and controllers will be created and the default layout file will have a login and register link.

You may not want the register part, removing the link from the template is not enough the routes and view/controller still exist. The can be deleted but a better way is to just disable the loading of the register view.

To do this open app/http/Controllers/Auth/RegisterController.php, this classes uses a RegistersUsers trait which contains a protected method to load the view. That’s in the core but you should never touch the core so instead overwrite that method by creating a method with the same name in RegisterController.php and instead of loading a view redirect to the home page or anywhere you like:

public function showRegistrationForm()
    return redirect('/');

While you’re at it disable the create method too:

protected function create(array $data)
    return redirect('/');
    /*return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),

This will stop the view from loading and stop the create from running. But if you change your mind later you can revert these back easily.

Do you know of a better way? let me know in the comments below.