|
1 | 1 | ## Filament
|
2 |
| -- Filament is used for functionality within this project, check how and where to follow existing project conventions. |
| 2 | +- Filament is by this application, check how and where to follow existing application conventions. |
3 | 3 | - 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 |
| -- 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. |
| 4 | +- You can use the `search-docs` tool to get information from the official Filament 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. |
5 | 5 |
|
6 |
| -## Artisan |
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. |
| 6 | +### Artisan |
| 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 valid arguments for other options when applicable. |
9 | 9 |
|
10 |
| -## Filament's Core Features |
| 10 | +### Filament's Core Features |
| 11 | +- Actions: Handle doing something within the application, 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. |
| 12 | +- Forms: Dynamic forms rendered within other features, such as resources, action modals, table filters, and more. |
| 13 | +- Infolists: Read-only lists of data. |
| 14 | +- Notifications: Flash notifications displayed to users within the application. |
11 | 15 | - Panels: The top-level container in Filament that can include all other features like pages, resources, forms, tables, notifications, actions, infolists, and widgets.
|
12 | 16 | - Resources: Static classes that are used to build CRUD interfaces for Eloquent models. Typically live in `app/Filament/Resources`.
|
13 |
| -- Tables: Interactive tables with filtering, sorting, pagination, and more. |
14 | 17 | - Schemas: Represent components that define the structure and behavior of the UI, such as forms, tables, or lists.
|
15 |
| -- Forms: Dynamic forms rendered within other features, such as resources, action modals, table filters, and more. |
16 |
| -- Infolists: Read-only list of data. |
17 |
| -- 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. |
18 |
| -- Notifications: Flash notifications to users within the app. |
| 18 | +- Tables: Interactive tables with filtering, sorting, pagination, and more. |
19 | 19 | - Widgets: Small component included within dashboards, often used for displaying data in charts, tables, or as a stat.
|
20 | 20 |
|
21 |
| -## Testing |
| 21 | +### Relationships |
| 22 | +- Determine if you can use the `relationship()` method on form components when you need `options` for a select, checkbox, repeater, or when building a `Fieldset`: |
| 23 | +@verbatim |
| 24 | +<code-snippet name="Relationship example for Form Select" lang="php"> |
| 25 | +Forms\Components\Select::make('user_id') |
| 26 | + ->label('Author') |
| 27 | + ->relationship('author') |
| 28 | + ->required(), |
| 29 | +</code-snippet> |
| 30 | +@endverbatim |
| 31 | + |
| 32 | +### Testing |
22 | 33 | - 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()`. |
| 34 | +- Ensure that you are authenticated to access the application within the test. |
| 35 | +- Filament uses Livewire, so start assertions with `livewire()` or `Livewire::test()`. |
25 | 36 |
|
26 |
| -### Example tests |
| 37 | +### Example Tests |
27 | 38 | @verbatim
|
28 |
| -<code-snippet name="Filament table test" lang="php"> |
| 39 | +<code-snippet name="Filament Table Test" lang="php"> |
29 | 40 | livewire(ListUsers::class)
|
30 | 41 | ->assertCanSeeTableRecords($users)
|
31 | 42 | ->searchTable($users->first()->name)
|
|
36 | 47 | ->assertCanNotSeeTableRecords($users->take($users->count() - 1));
|
37 | 48 | </code-snippet>
|
38 | 49 |
|
39 |
| -<code-snippet name="Filament create resource test" lang="php"> |
| 50 | +<code-snippet name="Filament Create Resource Test" lang="php"> |
40 | 51 | livewire(CreateUser::class)
|
41 | 52 | ->fillForm([
|
42 | 53 | 'name' => 'Howdy',
|
|
52 | 63 | ]);
|
53 | 64 | </code-snippet>
|
54 | 65 |
|
55 |
| -<code-snippet name="Testing multiple panels (setup())" lang="php"> |
| 66 | +<code-snippet name="Testing Multiple Panels (setup())" lang="php"> |
56 | 67 | use Filament\Facades\Filament;
|
| 68 | + |
57 | 69 | Filament::setCurrentPanel('app');
|
58 | 70 | </code-snippet>
|
59 | 71 |
|
60 |
| -<code-snippet name="Calling an action in a test" lang="php"> |
| 72 | +<code-snippet name="Calling an Action in a Test" lang="php"> |
61 | 73 | livewire(EditInvoice::class, [
|
62 | 74 | 'invoice' => $invoice,
|
63 | 75 | ])->callAction('send');
|
64 |
| - expect($invoice->refresh())->isSent()->toBeTrue(); |
65 |
| -</code-snippet> |
66 |
| -@endverbatim |
67 | 76 |
|
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(), |
| 77 | + expect($invoice->refresh())->isSent()->toBeTrue(); |
76 | 78 | </code-snippet>
|
77 | 79 | @endverbatim
|
0 commit comments