Package Data | |
---|---|
Maintainer Username: | rudiedirkx |
Maintainer Contact: | github@hotblocks.nl (Rudie Dirkx) |
Package Create Date: | 2017-04-02 |
Package Last Update: | 2021-05-07 |
Home Page: | https://packagist.org/packages/rdx/laravel-file-manager |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-12 15:05:07 |
Package Statistics | |
---|---|
Total Downloads: | 12 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 1 |
Keeps track of files and their usage. Works with an SQL backend by default.
php artisan vendor:publish
config/filemanager.php
php artisan migrate
^ This makes files
and files_usage
tables.rdx\filemanager\FileManagerServiceProvider::class
public function store(FileManager $files)
ManagedFile
records will be the primary source of files, not the file system.
$uploaded = $request['picture']; // Illuminate\Http\UploadedFile
$managed = $files->saveFile($uploaded); // in root dir
$managed = $files->saveFile($uploaded, 'some/sub/dir'); // in sub dir
File usage is useful to automatically delete orphaned files, or make sure used files aren't deleted.
Usage is kept by creating a FileUsageContract
. There are 2 provided, but
your app can make others.
To truly customize file usage, change the migration to add usage columns, AND create custom usage objects to reflect those columns.
// Generic FileUsage
$managed->addUsage(new FileUsage('type', 'more', 'specific', 'keys'));
// Save this file's usage for [type, more:specific:keys]
// Model bound ModelFileUsage
$managed->addUsage(new ModelFileUsage($user, 'picture'));
// Save this file's usage for [User, 14:picture]
@todo Can't delete used files @todo Auto delete unused files