PHP code example of ranitachi / filemanager-laravel
1. Go to this page and download the library: Download ranitachi/filemanager-laravel 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/ */
use Fachran\FileManager\Services\PermissionService;
$service = app(PermissionService::class);
// Grant read+write to a specific user on a folder
$service->grant(
resource: $folder,
grantableId: $userId,
grantableType: App\Models\User::class,
permissions: ['read', 'write'],
expiresAt: now()->addDays(30),
);
// Check permission
$canDelete = $service->can($user, $file, 'delete'); // bool
// In EventServiceProvider or config/filemanager.php 'listen' key:
use Fachran\FileManager\Events\FileUploaded;
class NotifyOnUpload
{
public function handle(FileUploaded $event): void
{
\Log::info("File uploaded: {$event->file->name} by user {$event->uploadedBy->id}");
}
}
bash
# One-step installation wizard
php artisan filemanager:install
# Purge files trashed more than 30 days ago (configurable)
php artisan filemanager:purge-trash
# Dry run (show what would be deleted)
php artisan filemanager:purge-trash --dry-run
# Custom retention period
php artisan filemanager:purge-trash --days=7
# Schedule it in Console/Kernel.php or routes/console.php
$schedule->command('filemanager:purge-trash --force')->weekly();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.