Missing required parameter for edit route redirect after creation error
I created a model EmploymentAnnouncement:
The migration:
If I create a new EmploymentAnnouncement from the admin panel, It is created but then at the redirect I get the error attached to this post.
class EmploymentAnnouncement extends Pivot
{
use HasFactory;
protected $table = 'employment_announcements';
// primary key
protected $primaryKey = 'id';
protected $fillable = [
'user_id',
'date',
'title',
'file_name',
];
public function user()
{
return $this->belongsTo(User::class, 'user_id', 'id', 'users');
}
}
The migration:
public function up(): void
{
Schema::create('employment_announcements', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->nullable()->constrained('users', 'id')->nullOnDelete();
$table->string('title');
$table->date('date');
$table->string('file_name');
$table->timestamps();
});
}
CreateEmploymentAnnouncement.php
<?php
namespace App\Filament\Resources\EmploymentAnnouncementResource\Pages;
use Filament\Pages\Actions;
use Filament\Resources\Pages\CreateRecord;
use App\Filament\Resources\EmploymentAnnouncementResource;
class CreateEmploymentAnnouncement extends CreateRecord
{
protected static string $resource = EmploymentAnnouncementResource::class;
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['user_id'] = auth()->id();
return $data;
}
}
If I create a new EmploymentAnnouncement from the admin panel, It is created but then at the redirect I get the error attached to this post.
Solution
Finally I found the answer to the problem thanks to @awcodes
it was solved here https://github.com/filamentphp/filament/issues/7592#issuecomment-1671997859
Basically somehow the models were extending the wrong class (Pivot instead of Model).
Thanks everyone.
it was solved here https://github.com/filamentphp/filament/issues/7592#issuecomment-1671997859
Basically somehow the models were extending the wrong class (Pivot instead of Model).
Thanks everyone.
GitHub
Package filament/filament Package Version ^2.0 Laravel Version ^10.10 Livewire Version No response PHP Version 8.2.6 Problem description After trying to create a model using the dashboard, the redi...



