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?
3 Replies
Patrick1989
Patrick19894mo ago
Good morning! a little bump
Solution
Tieme
Tieme4mo ago
You have used the wrong 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;
Patrick1989
Patrick19894mo ago
oh my god thanks