Laravel 5.3 - Routing as Auth::routes();
Hi! When i used php artisan make:auth in my routes/web.php added line Auth::routes(); But i cant find the list routes for Auth::routes(); can i use this method in my controllers and how?
I this it`s so cool if i ussed Products::routes(); Auth::routes();
I get what you mean, now. You're looking for an easy way to define all the routes for your other objects, I.E. Products, so you could use Product::routes().
Well, sure, you could make your own routes() function that does the same thing. The question is, where to put it, then. Auth refers to a facade, not an actual class, which is why you can access the non-static function statically.
If you really wanted to, you could create static methods on each of your controllers and call that in your web.php.
I.E.
static function routes() {
Route::group(array('prefix' => 'product'), function() {
Route::get('/{id?}', array('as' => 'product.index', 'uses' => 'ProductController@index'));
});
}
and then in web.php
\App\Http\Controllers\ProductController::routes();
@on3nx @tiborbesze86 is correct, the function exists to make the transition less painful and keep your routes file tidier. You can copy over all the routes from the function into the web.php file directly so that you can modify them, if you like. Then, just remove the Auth::routes() call.
You never want to modify any of the files inside the 'vendor' directory, unless you expect it to be a temporary thing. Those can be easily overwritten with an update to a composer package.
Please or to participate in this conversation.