© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Mahdi

FileUpload with relations

For example If User has a Profile
How to use FileUpload with Relations for saving multiple files for every user using
->multiple()
->multiple()




profile table
     $table->id();
     $table->foreignId('user_id')->constrained()->onDelete('cascade');
     $table->json('attachments')->nullable(); // for FileUpload multiable 
      // Other Columns 
     $table->timestamps();
     $table->id();
     $table->foreignId('user_id')->constrained()->onDelete('cascade');
     $table->json('attachments')->nullable(); // for FileUpload multiable 
      // Other Columns 
     $table->timestamps();


Profile Model
    protected $casts = [
        'attachments' => 'array'    
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
    protected $casts = [
        'attachments' => 'array'    
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }


User Model
   public function profile(): HasOne
    {
        return $this->HasOne(Profile::class);
    }
   public function profile(): HasOne
    {
        return $this->HasOne(Profile::class);
    }


User resource
->schema([
     FileUpload::make('attachments'))
        ->multiple(),
    ]),
->schema([
     FileUpload::make('attachments'))
        ->multiple(),
    ]),
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

FileUpload Image with morphOne relationship
FilamentFFilament / ❓┊help
3y ago
->modifyQueryUsing with relations
FilamentFFilament / ❓┊help
3y ago
FileUpload with relation
FilamentFFilament / ❓┊help
3y ago