PHP code example of scalexy / filament-bulk-upload

1. Go to this page and download the library: Download scalexy/filament-bulk-upload 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/ */

    

scalexy / filament-bulk-upload example snippets


use ScaleXY\FilamentBulkUpload\Forms\BulkMediaUpload;

BulkMediaUpload::make('media')
    ->collection('documents')
    ->disk('s3')
    ->maxFiles(1000)
    ->maxFileSize(976_562) // Optional override in KiB; omitted default is exactly 1 GB.
    ->acceptedFileTypes(['image/*', 'application/pdf'])
    ->uploadConcurrency(4)
    ->queue('bulk-uploads');

$panel->databaseTransactions();

DB::transaction(function () {
    $data = $this->form->getState();
    $record = Document::create($data);
    $this->form->model($record)->saveRelationships();
});

use Illuminate\Support\Facades\Schedule;

Schedule::command('bulk-upload:recover')->everyFiveMinutes()->withoutOverlapping();
Schedule::command('bulk-upload:cleanup')->hourly()->withoutOverlapping();

BulkMediaUpload::make('media')
    ->disk('tenant_s3')
    ->diskInstance(fn () => Storage::build($tenantS3Configuration));

// config/filament-bulk-upload.php
'auth_guard' => 'tenant_admin',
'connection' => 'tenant_connection', // The host's tenant-aware queue connection.
'middleware' => [
    'web',
    \Stancl\Tenancy\Middleware\InitializeTenancyByDomain::class,
    \Stancl\Tenancy\Middleware\PreventAccessFromUnwantedDomains::class,
    'auth:tenant_admin',
],
'tenant_resolver' => [\App\Providers\TenancyServiceProvider::class, 'bulkUploadTenantKey'],

public static function bulkUploadTenantKey(): ?string
{
    $key = tenant()?->getTenantKey();

    return $key === null ? null : (string) $key;
}
sh
composer n vendor:publish --tag=bulk-upload-config
php artisan vendor:publish --tag=bulk-upload-migrations
php artisan migrate
php artisan filament:assets
sh
php artisan queue:work --queue=bulk-uploads --timeout=300 --tries=5