© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
Kleis

How to access current model in custom view page

I made a livewire component and included it in a view page, but how can I access the current model in order to show the related data ?

Basically I want to make table of the relation with links to edit that relation, but to keep the edit page clean I dont want to include a relation manager there.

class ViewApartment extends Component implements HasForms, HasTable
{
    use InteractsWithTable;
    use InteractsWithForms;

    public function table(Table $table): Table
    {
        return $table
            ->query(function (\App\Models\Apartment $record) { \Log::debug($record); return \App\Models\Ownership::where("apartment_name", $record->name); })
            ->columns([
                TextColumn::make('name'),
            ])
            ->filters([])
            ->actions([])
            ->bulkActions([]);
    }

    public function render()
    {
        return view('livewire.view-apartment');
    }
}
class ViewApartment extends Component implements HasForms, HasTable
{
    use InteractsWithTable;
    use InteractsWithForms;

    public function table(Table $table): Table
    {
        return $table
            ->query(function (\App\Models\Apartment $record) { \Log::debug($record); return \App\Models\Ownership::where("apartment_name", $record->name); })
            ->columns([
                TextColumn::make('name'),
            ])
            ->filters([])
            ->actions([])
            ->bulkActions([]);
    }

    public function render()
    {
        return view('livewire.view-apartment');
    }
}
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

access current record from custom view
FilamentFFilament / ❓┊help
3y ago
Create custom resource view blade page and access model attributes
FilamentFFilament / ❓┊help
2y ago
Current record in custom page ?
FilamentFFilament / ❓┊help
3y ago