Skip to main content
Premium Members Only
Join to unlock this tutorial and all of our courses.
Premium Tutorial

Filament Custom Page Example with Repeater: Pick Game Winners

June 15, 2023
7 min read

Filament is a great admin panel system, but it often confuses users how to create a custom non-CRUD page in Filament that wouldn't be a typical Resource? This tutorial will provide an example.


The Initial Task

In this tutorial, we will create a custom Filament page with just one form. We will use a Repeater field for selecting the winners for the game.

This tutorial has three Models:

  • Game
  • Player
  • User

This is what the DB schema looks like:

filament custom page DB schema

Our task is to build a custom page to pick the winner players for a particular game. So it's not a typical "Game Edit" page but something different.

It will be a Repeater with 10 dropdowns.

custom page result

Important: after selecting the player in one dropdown, it should automatically be removed from all the other dropdowns.


Setup Filament Resource

We will have only one Filament Resource for Games.

app/Filament/Resources/GameResource.php:

use App\Models\Game;
use Filament\Resources\Form;
use Filament\Resources\Table;
use Filament\Resources\Resource;
use Filament\Tables\Columns\TextColumn;
use Filament\Forms\Components\TextInput;
 
class GameResource extends Resource
{
protected static ?string $model = Game::class;
 
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->required(),
]);
}
 
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name'),
]);
}
 
public static function getPages(): array
{
return [
'index' => Pages\ListGames::route('/'),
'create' => Pages\CreateGame::route('/create'),
'edit' => Pages\EditGame::route('/{record}/edit'),
];
}
}

Step 1. Empty Custom Page with a Link

So first, we need to create...

Premium Members Only

This advanced tutorial is available exclusively to Laravel Daily Premium members.

Premium membership includes:

Access to all premium tutorials
Video and Text Courses
Private Discord Channel
magic-thomas avatar

prependActions not works, actions works for me.

Nerijus avatar

prependActions works. It means you are doing something wrong. At least post what error you

magic-thomas avatar

no errors.. it just does not display 'Pick winners' button.

magic-thomas avatar

I found why now.

I created Resource with '--generate' option.

It made 'actions' automatically.

After removing 'actions', 'prependActions' only worked.

Steve Purcell avatar

prependActions is deprecated in Filament v3

Nerijus avatar

This tutorial was made when v3 wasn't launched.

Kay Vin avatar

how to get the index of the current row inside a repeater ?

Muhammad Sidiq Ali avatar

Any idea how to auto fill repeater instead? If we want all user to get chance to be winner. Instead of selecting 1 by 1.

Modestas avatar

Sorry, what do you mean by this? You can set ->default() on your repeater field and it should load the entries. But besides that - I did not understand the question :)

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.