Dynamic page title throws error
Hello, I'm trying to set a dynamic page title. Unfortunately when the mount method executes it throws an error related to the getRecord() method.
<?php
namespace App\Filament\Resources\TicketResource\Pages;
use App\Models\Ticket;
use Filament\Pages\Actions;
use Filament\Resources\Pages\ViewRecord;
use App\Filament\Resources\TicketResource;
class ViewTicket extends ViewRecord
{
protected static string $resource = TicketResource::class;
protected static string $view = 'filament.resources.tickets.pages.view-ticket';
protected static ?string $title = 'Ticket n.' ;
public function mount($record): void
{
$ticket = Ticket::find($record);
$this->number = $ticket->number;
// Imposta il titolo dinamicamente
ViewTicket::$title = "Ticket n.{$this->number}";
}
protected function getActions(): array
{
return [
//
];
}
} This is the code that I'm using and this is the error that I'm getting but I don't understand why, the error in my opinion comes from ($ticket=Ticket::find($record)): Filament\Resources\Pages\ViewRecord::getRecord(): Return value must be of type Illuminate\Database\Eloquent\Model, string returned