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;
}

}
No description
Solution:
- import the Participant use App\Models\Participant; ```php protected function getViewData(): array {...
Jump to solution
2 Replies
Solution
LeandroFerreira
LeandroFerreira9mo ago
- import the 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 in the view
thyk123
thyk123OP9mo ago
Hi, Thank you for responding to my question. Already try your solution and it works! Thank you so much, you're so great! Have a nice day!
Want results from more Discord servers?
Add your server