© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
12 replies
Gianmarco Varrone

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 [
            //
        ];
    }
}
<?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
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

title page
FilamentFFilament / ❓┊help
3y ago
Dynamic title in tabs
FilamentFFilament / ❓┊help
3y ago
Dynamic Page
FilamentFFilament / ❓┊help
2y ago
Remove page title
FilamentFFilament / ❓┊help
2y ago