3

I'm building a basic CMS with SEO slugs, so I want a catch all at the end of my routes to get the slug. So at the end of my routes file I added:

Route::get('/{page?}', ['as' => 'Page', 'middleware' => 'web', 'uses' => 'PageController@index']);

Which works fine, until I added Laravel File Manager, which has routes of its own. These routes are added after all of the routes in my main routes file. So now my catch all picks up anything meant for the file manager.

How can I load all other routes, including those in other vendor folders, before running the catch all? Is there a way I can state that the route must not match any route prefixed with laravel-filemanager? I've not been able to find anything on this in the Laravel documentation or through Google.

As requested here is my app providers:

'providers' => [

    /*
     * Laravel Framework Service Providers...
     */
    Illuminate\Auth\AuthServiceProvider::class,
    Illuminate\Broadcasting\BroadcastServiceProvider::class,
    Illuminate\Bus\BusServiceProvider::class,
    Illuminate\Cache\CacheServiceProvider::class,
    Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
    Illuminate\Cookie\CookieServiceProvider::class,
    Illuminate\Database\DatabaseServiceProvider::class,
    Illuminate\Encryption\EncryptionServiceProvider::class,
    Illuminate\Filesystem\FilesystemServiceProvider::class,
    Illuminate\Foundation\Providers\FoundationServiceProvider::class,
    Illuminate\Hashing\HashServiceProvider::class,
    Illuminate\Mail\MailServiceProvider::class,
    Illuminate\Pagination\PaginationServiceProvider::class,
    Illuminate\Pipeline\PipelineServiceProvider::class,
    Illuminate\Queue\QueueServiceProvider::class,
    Illuminate\Redis\RedisServiceProvider::class,
    Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
    Illuminate\Session\SessionServiceProvider::class,
    Illuminate\Translation\TranslationServiceProvider::class,
    Illuminate\Validation\ValidationServiceProvider::class,
    Illuminate\View\ViewServiceProvider::class,

    /*
     * Application Service Providers...
     */
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,

    Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
    Caffeinated\Modules\ModulesServiceProvider::class,
    Intervention\Image\ImageServiceProvider::class,
    Spatie\Activitylog\ActivitylogServiceProvider::class,
    Spatie\Permission\PermissionServiceProvider::class,
    Unisharp\Ckeditor\ServiceProvider::class,
    Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,

],
Styphon
  • 10,304
  • 9
  • 52
  • 86
  • can you list app providers? one solution maybe to list filemanager service provider before the route service provider – George G Jul 11 '16 at 10:44
  • @GeorgeGarchagudashvili I've added my app providers for you, the file manager is the last one. – Styphon Jul 11 '16 at 10:46

1 Answers1

4

Simply try to reorder the service providers in app.php like this:

'providers' => [

    /*
     * Laravel Framework Service Providers...
     */

    Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,
    ... 
    App\Providers\RouteServiceProvider::class,
    ... 

],

Anyway I always write RouteServiceProvider at the end of list, if not special case

George G
  • 7,443
  • 12
  • 45
  • 59
  • Thank you, didn't realise that the order of providers affected the order that routes are loaded. – Styphon Jul 11 '16 at 10:50
  • Welcome, glad to help you. laravel is big, so you can't realize everything until you have the problem of that case ;)) – George G Jul 11 '16 at 10:52