PHP code example of unifilemanager / filament-file-manager
1. Go to this page and download the library: Download unifilemanager/filament-file-manager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
unifilemanager / filament-file-manager example snippets
use Filament\Panel;
use UniFileManager\FilamentFileManager\FilamentFileManagerPlugin;
public function panel(Panel $panel): Panel
{
return $panel->plugins([
FilamentFileManagerPlugin::make(),
]);
}
use App\Filament\Pages\CustomFileManager;
FilamentFileManagerPlugin::make()
->page(CustomFileManager::class);
use App\Models\User;
use Illuminate\Support\Facades\Gate;
Gate::define('manageFileManager', function (User $user): bool {
return $user->is_admin === true;
});
'storage_areas' => [
'private' => [
'enabled' => true,
'disk' => 'local',
'root' => 'file-manager/private',
'visibility' => 'private',
],
'public' => [
'enabled' => true,
'disk' => 'public', // Or an S3/R2 disk configured for public delivery.
'root' => 'file-manager/public',
'visibility' => 'public',
],
],
use UniFileManager\FilamentFileManager\Filament\Forms\Components\UniFilePicker;
UniFilePicker::make('thumbnail')
->publicMedia()
->directory('courses/thumbnails')
->allowedMimeTypes(['image/*']);
UniFilePicker::make('thumbnail')
->uploadHeading('Add the course thumbnail')
->uploadDescription('Drop an image here or choose one from the library.');