© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
6 replies
Patrick

custom page throws error when adding trait InteractsWithRecord

I'm not sure what I'm missing. I've created a new custom page with this command:
php artisan make:filament-page RescheduleCourse --resource=CourseResource --type=custom
php artisan make:filament-page RescheduleCourse --resource=CourseResource --type=custom


Added the page to the resource, it displays, all good.
Now when I add
   use InteractsWithRecord;
   use InteractsWithRecord;
trait to it, I get this error:

Declaration of Filament\Actions\Concerns\InteractsWithRecord::getModel(): ?string must be compatible with Filament\Resources\Pages\Page::getModel(): string
Declaration of Filament\Actions\Concerns\InteractsWithRecord::getModel(): ?string must be compatible with Filament\Resources\Pages\Page::getModel(): string


When i remove the ? from the trait for testing, i get the the message that resolveRecord does not exist.

This is my page:

<?php

namespace App\Filament\Resources\CourseResource\Pages;

use App\Filament\Resources\CourseResource;
use Filament\Actions\Concerns\InteractsWithRecord;
use Filament\Resources\Pages\Page;

class RescheduleCourse extends Page
{
    use InteractsWithRecord;

    protected static string $resource = CourseResource::class;

    protected static string $view = 'filament.resources.course-resource.pages.reschedule-course';

    protected static ?string $title = 'Opleiding opnieuw inplannen';

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

namespace App\Filament\Resources\CourseResource\Pages;

use App\Filament\Resources\CourseResource;
use Filament\Actions\Concerns\InteractsWithRecord;
use Filament\Resources\Pages\Page;

class RescheduleCourse extends Page
{
    use InteractsWithRecord;

    protected static string $resource = CourseResource::class;

    protected static string $view = 'filament.resources.course-resource.pages.reschedule-course';

    protected static ?string $title = 'Opleiding opnieuw inplannen';

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


What am i doing wrong?
Solution
You have used the wrong
use
use
if i take a look at : https://filamentphp.com/docs/3.x/panels/resources/custom-pages#using-a-resource-record

change

use Filament\Actions\Concerns\InteractsWithRecord;
use Filament\Actions\Concerns\InteractsWithRecord;

To
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
Custom pages - Panel Builder - Filament
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 throws error with default code.
FilamentFFilament / ❓┊help
3y ago
Custom page adding Section
FilamentFFilament / ❓┊help
3y ago
Dynamic page title throws error
FilamentFFilament / ❓┊help
3y ago
Custom page with InteractsWithForms trait - select field issue
FilamentFFilament / ❓┊help
2y ago