Skip to content

Commit 77b2e14

Browse files
committed
guidelines: filament: initial version, paired with Dan on parts
1 parent 5adc0c1 commit 77b2e14

File tree

2 files changed

+72
-3
lines changed

2 files changed

+72
-3
lines changed

.ai/filament/4/core.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Filament 4
2+
3+
## Version 4 Changes To Focus On
4+
- File visibility is now `private` by default.
5+
- The `deferFilters` method from Filament v3 is now the default behavior in Filament v4, so users must click a button before the filters are applied to the table. To disable this behavior, you can use the `deferFilters(false)` method.
6+
- The `Grid`, `Section` and `Fieldset` layout components now do not span all columns by default.
7+
- The `all` pagination page method is not available for tables by default.
8+
- All action classes extend `Filament\Actions\Action`. No action classes exist in `Filament\Tables\Actions`.
9+
- Form & Infolist layout components have been moved to `Filament\Schemas\Components`, for example Grid, Section, Fieldset, Tabs, Wizard, etc..
10+
- A new `Repeater` component for Forms.
11+
- Icons now use the `Filament\Support\Icons\Heroicon` Enum by default. Other options are available and documented.

.ai/filament/core.blade.php

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
## Filament
22
- Filament is used for functionality within this project, check how and where to follow existing project conventions.
33
- Filament is a Server-Driven UI (SDUI) framework for Laravel. It allows developers to define user interfaces in PHP using structured configuration objects. It is built on top of Livewire, Alpine.js, and Tailwind CSS.
4-
- It is often used to build admin panels, dashboards, and form-based apps.
5-
- You can use the `search-docs` tool to get information from the official documentation when needed. This is very useful for artisan command arguments, specific code examples, and ensuring you're following idiomatic practices.
4+
- You can use the `search-docs` tool to get information from the official documentation when needed. This is very useful for artisan command arguments, specific code examples, testing functionality, relationship management, and ensuring you're following idiomatic practices.
65

76
## Artisan
8-
- You must use the Filament specific artisan commands to create Filament classes and components. You can find these with the `list-artisan-commands` tool.
7+
- You must use the Filament specific artisan commands to create new files or components for Filament. You can find these with the `list-artisan-commands` tool, or with `php artisan` and the `--help` option.
8+
- Inspect the required options, always pass `--no-interaction`, and other options with valid arguments.
99

1010
## Filament's Core Features
1111
- Panels: The top-level container in Filament that can include all other features like pages, resources, forms, tables, notifications, actions, infolists, and widgets.
@@ -17,3 +17,61 @@
1717
- Actions: Handle doing something within the app, often with a button or link. Actions encapsulate the UI, the interactive modal window, and the logic that should be executed when the modal window is submitted. They can be used anywhere in the UI and are commonly used to perform one-time actions like deleting a record, sending an email, or updating data in the database based on modal form input.
1818
- Notifications: Flash notifications to users within the app.
1919
- Widgets: Small component included within dashboards, often used for displaying data in charts, tables, or as a stat.
20+
21+
## Testing
22+
- It's important to test Filament functionality for user satisfaction.
23+
- Ensure that you are authenticated to access the app within the test.
24+
- Filament uses Livewire so start assertions with `livewire()` or `Livewire::test()`.
25+
26+
### Example tests
27+
@verbatim
28+
<code-snippet name="Filament table test" lang="php">
29+
livewire(ListUsers::class)
30+
->assertCanSeeTableRecords($users)
31+
->searchTable($users->first()->name)
32+
->assertCanSeeTableRecords($users->take(1))
33+
->assertCanNotSeeTableRecords($users->skip(1))
34+
->searchTable($users->last()->email)
35+
->assertCanSeeTableRecords($users->take(-1))
36+
->assertCanNotSeeTableRecords($users->take($users->count() - 1));
37+
</code-snippet>
38+
39+
<code-snippet name="Filament create resource test" lang="php">
40+
livewire(CreateUser::class)
41+
->fillForm([
42+
'name' => 'Howdy',
43+
'email' => '[email protected]',
44+
])
45+
->call('create')
46+
->assertNotified()
47+
->assertRedirect();
48+
49+
assertDatabaseHas(User::class, [
50+
'name' => 'Howdy',
51+
'email' => '[email protected]',
52+
]);
53+
</code-snippet>
54+
55+
<code-snippet name="Testing multiple panels (setup())" lang="php">
56+
use Filament\Facades\Filament;
57+
Filament::setCurrentPanel('app');
58+
</code-snippet>
59+
60+
<code-snippet name="Calling an action in a test" lang="php">
61+
livewire(EditInvoice::class, [
62+
'invoice' => $invoice,
63+
])->callAction('send');
64+
expect($invoice->refresh())->isSent()->toBeTrue();
65+
</code-snippet>
66+
@endverbatim
67+
68+
## Relationships
69+
- Check if you can use the `relationship()` method on form components when needing `options` for a select, checkbox, repeater, or when building a Fieldset:
70+
@verbatim
71+
<code-snippet name="Relationship example for Form Select" lang="php">
72+
Forms\Components\Select::make('user_id')
73+
->label('Author')
74+
->relationship('author')
75+
->required(),
76+
</code-snippet>
77+
@endverbatim

0 commit comments

Comments
 (0)