barryvdh / laravel-elfinder

elFinder bundle for Laravel
738 stars 169 forks source link

having two different routes to laravel elfinder? #331

Open prescriptionlifeline opened 4 months ago

prescriptionlifeline commented 4 months ago

On my Laravel site I have two different types of users - admins and non-admin. Both admins and non admins can view certain pages but there are other pages that only admins can view.

For the Admin pages I'm using Laravel Backpack with backpack/filemanager, which in turn, is a thin wrapper around this project. Like I want admins to be able to upload files but I do not want non admins uploading files.

To facilitate this what I was thinking I could do is to have two separate instances of Laravel Elfinder. The one that backpack/filemanager created and another one for non-admins. On the non-admin one I was thinking I'd prevent uploads by hiding the buttons / menu options that give the ability to do uploads. Maybe there are better methods to prevent people from uploading files but if I can't have two separate instances of Laravel Elfinder then there's no point in pursuing those other options.

Anyway, the problem with my approach is that I already have a config/elfinder.php. backpack/filemanager created it and that one already defines a route:

    'route' => [
        'prefix' => config('backpack.base.route_prefix', 'admin').'/elfinder',
        'middleware' => ['web', config('backpack.base.middleware_key', 'admin')], //Set to null to disable middleware filter
    ],

Like from that it's unclear to me how I could have two separate routes for two separate laravel-elfinder instances, if that's even possible at all.

I suppose I could create two Laravel instances and use mod_proxy_http to make it so that requests to /admin are served up from one Laravel instance and requests to everything else are served up via another Laravel instance but that has challenges of its own and I'd rather not do that! I suppose another possibility would be to use a completely different file manager for the non-admin one (maybe alexusmai/laravel-file-manager) but idk... I'm already using laravel elfinder and would prefer to re-use it!