F
Filament8mo ago
jals65

Record variable type change to string if i add the mount function on my viewrecord page

Hi, i'm trying to add an additional viewRecord page on my resource to show some info in an specific type of records. If the record doen't have this specific type, i need to block accessing the page throwing a 404 error. So i'm trying to make a validation on the mount hook of this page. The problem is with the record. If I don't add the mount function, the $this->record is a Model of my record, but when I add the mount function, it it's a string, the name of the record.
Solution:
Hi, you should ideally try and inspect the extended class. which would showm you can do: ```php public function mount(int | string $record): void {...
Jump to solution
3 Replies
jals65
jals65OP8mo ago
hi?
Solution
toeknee
toeknee8mo ago
Hi, you should ideally try and inspect the extended class. which would showm you can do:
public function mount(int | string $record): void
{
parent::mount($record);

if($this->record && $this->record->value === 'test') {
abort(403);
}
}
public function mount(int | string $record): void
{
parent::mount($record);

if($this->record && $this->record->value === 'test') {
abort(403);
}
}
jals65
jals65OP8mo ago
Thanks, I was missing that: parent::mount($record);
Want results from more Discord servers?
Add your server