Edit a record without providing the record parameter

Hi Filament Community, I am just getting a hang of FilamentPHP and I am working on a scenario where I want to let user edit his relationship related information inside the user panel. I have a UserResource created it has a Page named EditEducation which extends EditPage and route name is /me/education Doing so throws following exception
No description
8 Replies
toeknee
toeknee13mo ago
You would need to edit the mount function on the page to remove the required $id and instead load the record from the auth()->user(
Hasnain Haider
Hasnain HaiderOP13mo ago
If I override the mount without parameter and set the record from auth()->user() it is of no use because the mount function in the parent class requires a parameter
toeknee
toeknee13mo ago
Correct, but you define it in the override
public function mount() {

$id = auth()->id;
return parent::mount($id);
}
public function mount() {

$id = auth()->id;
return parent::mount($id);
}
Hasnain Haider
Hasnain HaiderOP13mo ago
This is what happens
No description
toeknee
toeknee13mo ago
Ok ok try:
public function mount($id = 0) {

$id = auth()->id;
$this->record = $id;
return parent::mount($id);
}
public function mount($id = 0) {

$id = auth()->id;
$this->record = $id;
return parent::mount($id);
}
Hasnain Haider
Hasnain HaiderOP13mo ago
Not working either, the idea is this I have one resource but I want each relationship to be on a dedicated page What other possible routes do we have at the moment
toeknee
toeknee13mo ago
Just create a custom page if need be? How have you defined the route?
LeandroFerreira
LeandroFerreira13mo ago
mount should be void
public function mount(int|string $record): void
{
$this->record = $this->resolveRecord(auth()->id());

$this->authorizeAccess();

$this->fillForm();

$this->previousUrl = url()->previous();
}
public function mount(int|string $record): void
{
$this->record = $this->resolveRecord(auth()->id());

$this->authorizeAccess();

$this->fillForm();

$this->previousUrl = url()->previous();
}
Want results from more Discord servers?
Add your server