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;
    }
    
}
image.png
Solution
  • import the Participant use App\Models\Participant;
protected function getViewData(): array
{
    $getData = Participant::where('idRootInfo',$this->record->id)
        ->pluck('nameParticipant','ulid');

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


use $items in the view
Was this page helpful?