Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.6] Add unset() method in FilesystemManager #24057

Merged
merged 2 commits into from
May 2, 2018
Merged

Conversation

fgilio
Copy link
Contributor

@fgilio fgilio commented Apr 30, 2018

I'm building a multi tenant system and I had to add this method to be able to update the disk's root property dynamically when switching tenants. For example, in this app we switch tenants when processing data inside queued jobs.
The disk config is cached, so this method needs to be called manually before making changes to the config. After the disk is used again the new config is cached automatically.

Here is an example of an app with disks for photos and videos:

// First we unset the disks
app('filesystem')->unset(['photos', 'videos']);

// Apply the tenant's slug as the disk path root
Config::set('filesystems.disks.photos.root', $this->currentTenant->slug);
Config::set('filesystems.disks.videos.root', $this->currentTenant->slug);

The method accepts an array of names, but if a single string is more appropriate I can change it.

I'm building a multi tenant system and I had to add this method to be able to update the disk's roots dynamically when switching tenants. For exampel, in this app we need to switch tenants when running queue jobs.
The disk config is cached, so this method needs to be called manually before making changes to the config. After the disk is used again the new config is cached automatically.

Here is an example of a system with disks for photos and videos:
```php
// First we unset the disks
app('filesystem')->unset(['photos', 'videos']);

// Apply the tenant's slug as the disk path root
Config::set('filesystems.disks.photos.root', $this->currentTenant->slug);
Config::set('filesystems.disks.videos.root', $this->currentTenant->slug);
```
@fgilio fgilio changed the title Add unset() method in FilesystemManager [5.6] Add unset() method in FilesystemManager Apr 30, 2018
@taylorotwell taylorotwell merged commit 2c968e1 into laravel:5.6 May 2, 2018
@fgilio
Copy link
Contributor Author

fgilio commented May 2, 2018

Thanks for merging!

@vlakoff
Copy link
Contributor

vlakoff commented May 3, 2018

How about accepting a single string as well?

@vlakoff
Copy link
Contributor

vlakoff commented May 3, 2018

Nevermind, Taylor already did it in subsequent commit cbfb4fb :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants