I'm trying to set filesystem configuration value dynamically in controller level. (I think it's almost impossible).
For example:
'sftp' => [
'driver' => 'sftp',
'host' => env('SFTP_HOST'),
'port' => intval(env('SFTP_PORT')),
'username' => env('SFTP_USERNAME'),
'password' => env('SFTP_PASSWORD'),
],
This is my SFTP disk configuration value in filesystems.php
.
I will have host, port, username, password
values dynamically from database table. (There will be multiple records.)
And I'm trying to connect File System using File Manager Package. (ie: https://github.com/alexusmai/laravel-file-manager)
When I used static values, it worked well.
Now I'm trying to set it dynamically in Controller level.
$myConfigArrayvalue = MyModel::find($id);
config(['filesystems.disk.sftp' => $myConfigArrayvalue);
When I dd(config('filesystems.disk.sftp'))
in controller or view, it shows dynamically value.
but in File Manager Package (ServiceProvider), it was showing empty value so when I go to view page, it didn't work.
I think this is because ServiceProvider was called before Controller.
Can anyone please help me how to do this?