Filament Reserved Keywords?

I have a model called Message when I try to create a message in Filament, admin/messages/create returns a 404. Is messages or message a reserved keyword? Can't seem to pinpoint why this is occuring otherwise.
5 Replies
Tally
Tally2mo ago
Did you create your Resource?
php artisan make:filament-resource
php artisan make:filament-resource
Dennis Koch
Dennis Koch2mo ago
It's hard to help without any code.
ahinkle
ahinkle2mo ago
<?php

namespace App\Filament\Resources;

use App\Filament\Resources\MessageResource\Pages;
use App\Models\Message;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;

class MessageResource extends Resource
{
protected static ?string $model = Message::class;

protected static ?string $navigationIcon = 'heroicon-o-book-open';

public static function form(Form $form): Form
{
return $form
->schema([
//
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
//
])
->filters([
//
])
->actions([
Tables\Actions\ViewAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
])
->emptyStateActions([
Tables\Actions\CreateAction::make(),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListMessages::route('/'),
'view' => Pages\ViewMessage::route('/{record}'),
'create' => Pages\CreateMessage::route('/create'),
'edit' => Pages\EditMessage::route('/{record}/edit'),
];
}
}
<?php

namespace App\Filament\Resources;

use App\Filament\Resources\MessageResource\Pages;
use App\Models\Message;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;

class MessageResource extends Resource
{
protected static ?string $model = Message::class;

protected static ?string $navigationIcon = 'heroicon-o-book-open';

public static function form(Form $form): Form
{
return $form
->schema([
//
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
//
])
->filters([
//
])
->actions([
Tables\Actions\ViewAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
])
->emptyStateActions([
Tables\Actions\CreateAction::make(),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListMessages::route('/'),
'view' => Pages\ViewMessage::route('/{record}'),
'create' => Pages\CreateMessage::route('/create'),
'edit' => Pages\EditMessage::route('/{record}/edit'),
];
}
}
1. Create a Message model, then a resource 2. admin/messages/create is a 404 Sorry - updated. Thanks!
Dennis Koch
Dennis Koch2mo ago
Order is important: You move the view route before the create route. Now it's looking for a message with ID create:
'view' => Pages\ViewMessage::route('/{record}'),
'create' => Pages\CreateMessage::route('/create'),
'view' => Pages\ViewMessage::route('/{record}'),
'create' => Pages\CreateMessage::route('/create'),
ahinkle
ahinkle2mo ago
Ah perfect. That was it. Thanks so much