© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
4 replies
thyk123

how to call model inside custom page resource

Hi, I created a custom page ViewTickets from RootInformationResource.
I want to fetch the hasMany relation data from the Participants table, but instead, I got an error like this.
How to use the model inside the custom page resource I think I wrote the code wrong
Thank you, and may your day be blessed!

<?php

namespace App\Filament\Resources\RootInformationResource\Pages;

use App\Filament\Resources\RootInformationResource;
use Filament\Resources\Pages\Page;
use Filament\Resources\Pages\Concerns\InteractsWithRecord;

class ViewTickets extends Page
{
    use InteractsWithRecord;

    protected static string $resource = RootInformationResource::class;

    protected static string $view = 'filament.resources.root-information-resource.pages.view-tickets';

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

    public function getViewData(): array
    {
        $getData = Participant::where('idRootInfo',$this->record->id)->pluck('nameParticipant','ulid');
        return $getData;
    }
    
}
<?php

namespace App\Filament\Resources\RootInformationResource\Pages;

use App\Filament\Resources\RootInformationResource;
use Filament\Resources\Pages\Page;
use Filament\Resources\Pages\Concerns\InteractsWithRecord;

class ViewTickets extends Page
{
    use InteractsWithRecord;

    protected static string $resource = RootInformationResource::class;

    protected static string $view = 'filament.resources.root-information-resource.pages.view-tickets';

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

    public function getViewData(): array
    {
        $getData = Participant::where('idRootInfo',$this->record->id)->pluck('nameParticipant','ulid');
        return $getData;
    }
    
}
image.png
Solution
- import the Participant
use App\Models\Participant;
use App\Models\Participant;


protected function getViewData(): array
{
    $getData = Participant::where('idRootInfo',$this->record->id)
        ->pluck('nameParticipant','ulid');

    return [
        'items' => $getData
    ];
}
protected function getViewData(): array
{
    $getData = Participant::where('idRootInfo',$this->record->id)
        ->pluck('nameParticipant','ulid');

    return [
        'items' => $getData
    ];
}


use
$items
$items
in the view
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Custom page access inside resource folder
FilamentFFilament / ❓┊help
2y ago
custom page(non resource page)
FilamentFFilament / ❓┊help
2y ago
How to call function inside custom form field
FilamentFFilament / ❓┊help
2y ago
Custom page in resource
FilamentFFilament / ❓┊help
3y ago