ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filamentโ€ข3y agoโ€ข
8 replies
kennyhorna

Set record in ViewRecord page

Hi, I'm creating a custom panel for a customer role. So I would like to limit the view/edit actions for this customer to only be able manage his/hers business.

So my idea is to create BusinessResource and then use the ViewBusiness to display the data using an infolist, so then I can add a new entry in the nav pointing to the view page directly.

My problem right now is that I cannot set the record in the view page.

So this is my
Business::getPages()
Business::getPages()
:
return [
    'view' => Pages\ViewBusiness::route('/my-business'),
];
return [
    'view' => Pages\ViewBusiness::route('/my-business'),
];


I've tried to set the record using this 3 methods but so far no luck:

public function getRecord(): Model
{
    return auth()->user()->business;
}

protected function resolveRecord(int|string|null $key): Model
{
    return auth()->user()->business;
}

public function setRecord(Model|int|string|null $record): void
{
    $this->record = auth()->user()->business;
}
public function getRecord(): Model
{
    return auth()->user()->business;
}

protected function resolveRecord(int|string|null $key): Model
{
    return auth()->user()->business;
}

public function setRecord(Model|int|string|null $record): void
{
    $this->record = auth()->user()->business;
}


But I'm still getting:
Unable to resolve dependency [Parameter #0 [ <required> string|int $record ]] in class Filament\Resources\Pages\ViewRecord
Unable to resolve dependency [Parameter #0 [ <required> string|int $record ]] in class Filament\Resources\Pages\ViewRecord


How could I achieve this? Or maybe some guidance in case there's an easier approach.

Thanks in advance ๐Ÿ™‚
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

Use Action in custom ViewRecord page
FilamentFFilament / โ“โ”Šhelp
3y ago
How to get record model in ViewRecord action?
FilamentFFilament / โ“โ”Šhelp
3y ago
viewrecord on modal not showing record
FilamentFFilament / โ“โ”Šhelp
2y ago
Actions in footer (bottom of ViewRecord page)
FilamentFFilament / โ“โ”Šhelp
3y ago