Chaddus Maximus
Chaddus Maximus
FFilament
Created by Chaddus Maximus on 11/4/2024 in #❓┊help
Filament File Upload Custom Relationship
Hello, I've been using Filament to build a Dashboard that has a file upload, I've searched through the documentation and github and could not find an answer so I'm hoping I will find one here. I want to have a file upload that will create a new eloquent model and save it to the database. I have a JobPosting model that it's name, content, it's tied to the user and it should have mutliple files that are tied to it. So for example a Job Posting of the name 'New Job' can have three images and one PDF document uploaded. Migration code:
public function up(): void
{
Schema::create('job_posting_files', function (Blueprint $table) {
$table->id();
$table->string('original_name');
$table->string('stored_name');
$table->foreignId('job_posting_id')->nullable()->constrained()->cascadeOnDelete();
$table->timestamps();
});
}
public function up(): void
{
Schema::create('job_posting_files', function (Blueprint $table) {
$table->id();
$table->string('original_name');
$table->string('stored_name');
$table->foreignId('job_posting_id')->nullable()->constrained()->cascadeOnDelete();
$table->timestamps();
});
}
This model is called JobPostingFile and it has it's original name, the stored name which will be hashed and it's tied to a JobPosting. One Job Posting can have multiple Job Posting Files. Migration code:
public function up(): void
{
Schema::create('job_posting_files', function (Blueprint $table) {
$table->id();
$table->string('original_name');
$table->string('stored_name');
$table->foreignId('job_posting_id')->nullable()->constrained()->cascadeOnDelete();
$table->timestamps();
});
}
public function up(): void
{
Schema::create('job_posting_files', function (Blueprint $table) {
$table->id();
$table->string('original_name');
$table->string('stored_name');
$table->foreignId('job_posting_id')->nullable()->constrained()->cascadeOnDelete();
$table->timestamps();
});
}
How do I make a form in Filament where I can upload multiple files and for each of those files a new JobPostingFile model will be created, it's original name, stored name will be created and it will be linked to the JobPosting model by it's id? Help would be really appreciated, I have spent a month and a half and could not find a solution.
6 replies