CustomPage for related model

I just started out experiemented with Filament, and I'm not sure if I'm using it wrong. Let me explain: I have a model named Tenancy(Don't mistake this for multi-tenancy). Each Tenancy has a Conversation, as in a chat with multiple messages from different users. As you might expect conversation doesn't really fit into the typical "CRUD" layout. I obviously want a list of messages as well as a input field on the same page.
My idea was to create a custom page that takes the ID of a tenancy and then from that find the conversation and load in all messages. This were to be served at /app/{tenant}/tenancies/{record}/conversation. Be aware that it is a multi-tenant project, however Tenancy model has nothing to do with that.
No description
No description
1 Reply
RasmusGP
RasmusGP6mo ago
So I have done the following: - Blade Template: I created chat.blade.php at resources/views/filament/app/pages/chat.blade.php for displaying messages and a send button:
<x-filament-panels::page>
<div>
<div><h2>Title</h2></div>
<div>Messages container</div>
<div><input type="text"/><button>Send</button></div>
</div>
</x-filament-panels::page>
<x-filament-panels::page>
<div>
<div><h2>Title</h2></div>
<div>Messages container</div>
<div><input type="text"/><button>Send</button></div>
</div>
</x-filament-panels::page>
- Tenant-Specific Route: Configured within app/Providers/Filament/AppPanelProvider.php
public function panel(Panel $panel): Panel
{
return $panel
... Other functions
->tenantRoutes(function ($router) {
Route::get('/tenancies/{record}/conversation', [Conversation::class, 'mount'])->name('filament.app.tenancies.conversation');
})
...
Other functions
public function panel(Panel $panel): Panel
{
return $panel
... Other functions
->tenantRoutes(function ($router) {
Route::get('/tenancies/{record}/conversation', [Conversation::class, 'mount'])->name('filament.app.tenancies.conversation');
})
...
Other functions
- Custom Page: Defined in app/Filament/App/Resources/TenancyResource/Pages/Conversation.php to load the conversation:
class Conversation extends Page
{
use InteractsWithRecord;

protected static ?string $slug = 'conversation/{id}';
protected static bool $shouldRegisterNavigation = false;

public function mount(int | string $record, Tenancy $tenancy): void
{
// $tenancy = (new Tenancy)->findOrFail($record);
$conversation = $tenancy->conversation;
$this->record = $conversation;
}

protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.app.pages.chat'; // Points to blade component
}
class Conversation extends Page
{
use InteractsWithRecord;

protected static ?string $slug = 'conversation/{id}';
protected static bool $shouldRegisterNavigation = false;

public function mount(int | string $record, Tenancy $tenancy): void
{
// $tenancy = (new Tenancy)->findOrFail($record);
$conversation = $tenancy->conversation;
$this->record = $conversation;
}

protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.app.pages.chat'; // Points to blade component
}
Despite these setups, accessing app/{tenant}/tenancies/{record}/conversation only shows a white screen, with no errors logged. Could this be an issue with how I'm implementing Filament for non-standard use cases, or am I missing something in my configuration? Any guidance would be appreciated.
Want results from more Discord servers?
Add your server