The Problem
During one of our projects, we developed a backend for a customer. As you can imagine, we had a situation where users should not be able to register themselves to the backend. Ok, what can we do?
The first thing that came to mind was, to go through all the standard template files and remove everything where registration was involved.
Sounds ok, right? But, what if at some point the users need to be able to register? You would have to undo all the work you did earlier, which is inefficient and labor intensive!
No worries, we found a pretty neat solution we want to show you!
The Solution
Auth::routes(['register' => false]);
If you have used Laravel's awesome php artisan make:auth command before, then you probably know that you have to place the Auth::routes() call in the web.php file in order to register all the routes.
What we are doing here is, telling Laravel that we don't want the registration part of the Auth routes.
After passing this little array as a parameter to the routes call, the Register link in the top bar should disappear, and even when you access /register manually, you should get a 404.
This is a pretty cool solution to a common problem and if our customer now wants registration in his backend again, it is just a simple one-liner we have to remove.
Have fun and try it out yourself!

