1

I just got an issue , i have 2 problems :

  1. I want create a custom route for fast using without copy past code many time. Example Laravel 5 have default Route:resource (...) to make Restful! But i want to make my custom route function , Route:api(...) , Route:xxx(...) ... and I can custom it what I want !

  2. How can I use multi route file ? Example : I can define route in App\User\route.user.php , App\Book\route.book.php .... because now, I can only use route file in route folder default !

Shayne
  • 65
  • 2
  • 11

1 Answers1

2

I do not understand properly question 1. But for question 2, try this:

Go to app/Providers/RouteServiceProvider.php. Look for the function mapWebRoutes(). The line

require base_path('routes/web.php');

Duplicate it and change so you now have :

require base_path('routes/web.php');
require base_path('app/User/route.user.php');
require base_path('app/Whatever/route.whatever.php');

And laravel will load all routes within those files. Now, I've tested this, it works (Laravel 5.3) but I can't guarantee anything or if there are going to be conflicts with routes (duplicates). But yeah, it works.

EddyTheDove
  • 12,979
  • 2
  • 37
  • 45
  • yeah, thank Eddy, finally I found solution for question 2! Question 1 I want to make a new static function for Route , example Route::myfunction() . and in myFunction() I can define with GET method will map to Controller@func1 , with POST will map to Controller@func2 , with PUT method will map to Controller@func3 ... – Shayne Jan 31 '17 at 13:02