Skip to content

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

Merged
taylorotwell merged 2 commits into
laravel:5.6from
fgilio:patch-1
May 2, 2018
Merged

taylorotwell merged 2 commits into
laravel:5.6from
fgilio:patch-1

Conversation

@fgilio

@fgilio fgilio commented Apr 30, 2018 •

Copy link
Copy Markdown
Contributor

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

fgilio commented May 2, 2018

Copy link
Copy Markdown
Contributor Author

Thanks for merging!

@vlakoff

vlakoff commented May 3, 2018

Copy link
Copy Markdown
Contributor

How about accepting a single string as well?

@vlakoff

vlakoff commented May 3, 2018

Copy link
Copy Markdown
Contributor

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