further layout preview fixes
This commit is contained in:
181
AGENTS.md
181
AGENTS.md
@@ -95,7 +95,7 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
|
||||
## Foundational Context
|
||||
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
|
||||
|
||||
- php - 8.3.6
|
||||
- php - 8.3.24
|
||||
- filament/filament (FILAMENT) - v4
|
||||
- inertiajs/inertia-laravel (INERTIA) - v2
|
||||
- laravel/framework (LARAVEL) - v12
|
||||
@@ -207,108 +207,20 @@ protected function isAccessible(User $user, ?string $path = null): bool
|
||||
- Typically, keys in an Enum should be TitleCase. For example: `FavoritePerson`, `BestLake`, `Monthly`.
|
||||
|
||||
|
||||
=== filament/core rules ===
|
||||
=== herd rules ===
|
||||
|
||||
## Filament
|
||||
- Filament is used by this application, check how and where to follow existing application conventions.
|
||||
- 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.
|
||||
- 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.
|
||||
- Utilize static `make()` methods for consistent component initialization.
|
||||
## Laravel Herd
|
||||
|
||||
### Artisan
|
||||
- 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.
|
||||
- Inspect the required options, always pass `--no-interaction`, and valid arguments for other options when applicable.
|
||||
|
||||
### Filament's Core Features
|
||||
- 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.
|
||||
- Forms: Dynamic forms rendered within other features, such as resources, action modals, table filters, and more.
|
||||
- Infolists: Read-only lists of data.
|
||||
- Notifications: Flash notifications displayed to users within the application.
|
||||
- Panels: The top-level container in Filament that can include all other features like pages, resources, forms, tables, notifications, actions, infolists, and widgets.
|
||||
- Resources: Static classes that are used to build CRUD interfaces for Eloquent models. Typically live in `app/Filament/Resources`.
|
||||
- Schemas: Represent components that define the structure and behavior of the UI, such as forms, tables, or lists.
|
||||
- Tables: Interactive tables with filtering, sorting, pagination, and more.
|
||||
- Widgets: Small component included within dashboards, often used for displaying data in charts, tables, or as a stat.
|
||||
|
||||
### Relationships
|
||||
- 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`:
|
||||
|
||||
<code-snippet name="Relationship example for Form Select" lang="php">
|
||||
Forms\Components\Select::make('user_id')
|
||||
->label('Author')
|
||||
->relationship('author')
|
||||
->required(),
|
||||
</code-snippet>
|
||||
- The application is served by Laravel Herd and will be available at: https?://[kebab-case-project-dir].test. Use the `get-absolute-url` tool to generate URLs for the user to ensure valid URLs.
|
||||
- You must not run any commands to make the site available via HTTP(s). It is _always_ available through Laravel Herd.
|
||||
|
||||
|
||||
## Testing
|
||||
- It's important to test Filament functionality for user satisfaction.
|
||||
- Ensure that you are authenticated to access the application within the test.
|
||||
- Filament uses Livewire, so start assertions with `livewire()` or `Livewire::test()`.
|
||||
=== tests rules ===
|
||||
|
||||
### Example Tests
|
||||
## Test Enforcement
|
||||
|
||||
<code-snippet name="Filament Table Test" lang="php">
|
||||
livewire(ListUsers::class)
|
||||
->assertCanSeeTableRecords($users)
|
||||
->searchTable($users->first()->name)
|
||||
->assertCanSeeTableRecords($users->take(1))
|
||||
->assertCanNotSeeTableRecords($users->skip(1))
|
||||
->searchTable($users->last()->email)
|
||||
->assertCanSeeTableRecords($users->take(-1))
|
||||
->assertCanNotSeeTableRecords($users->take($users->count() - 1));
|
||||
</code-snippet>
|
||||
|
||||
<code-snippet name="Filament Create Resource Test" lang="php">
|
||||
livewire(CreateUser::class)
|
||||
->fillForm([
|
||||
'name' => 'Howdy',
|
||||
'email' => 'howdy@example.com',
|
||||
])
|
||||
->call('create')
|
||||
->assertNotified()
|
||||
->assertRedirect();
|
||||
|
||||
assertDatabaseHas(User::class, [
|
||||
'name' => 'Howdy',
|
||||
'email' => 'howdy@example.com',
|
||||
]);
|
||||
</code-snippet>
|
||||
|
||||
<code-snippet name="Testing Multiple Panels (setup())" lang="php">
|
||||
use Filament\Facades\Filament;
|
||||
|
||||
Filament::setCurrentPanel('app');
|
||||
</code-snippet>
|
||||
|
||||
<code-snippet name="Calling an Action in a Test" lang="php">
|
||||
livewire(EditInvoice::class, [
|
||||
'invoice' => $invoice,
|
||||
])->callAction('send');
|
||||
|
||||
expect($invoice->refresh())->isSent()->toBeTrue();
|
||||
</code-snippet>
|
||||
|
||||
|
||||
=== filament/v4 rules ===
|
||||
|
||||
## Filament 4
|
||||
|
||||
### Important Version 4 Changes
|
||||
- File visibility is now `private` by default.
|
||||
- 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.
|
||||
- The `Grid`, `Section`, and `Fieldset` layout components no longer span all columns by default.
|
||||
- The `all` pagination page method is not available for tables by default.
|
||||
- All action classes extend `Filament\Actions\Action`. No action classes exist in `Filament\Tables\Actions`.
|
||||
- The `Form` & `Infolist` layout components have been moved to `Filament\Schemas\Components`, for example `Grid`, `Section`, `Fieldset`, `Tabs`, `Wizard`, etc.
|
||||
- A new `Repeater` component for Forms has been added.
|
||||
- Icons now use the `Filament\Support\Icons\Heroicon` Enum by default. Other options are available and documented.
|
||||
|
||||
### Organize Component Classes Structure
|
||||
- Schema components: `Schemas/Components/`
|
||||
- Table columns: `Tables/Columns/`
|
||||
- Table filters: `Tables/Filters/`
|
||||
- Actions: `Actions/`
|
||||
- Every change must be programmatically tested. Write a new test or update an existing test, then run the affected tests to make sure they pass.
|
||||
- Run the minimum number of tests needed to ensure code quality and speed. Use `php artisan test` with a specific filename or filter.
|
||||
|
||||
|
||||
=== inertia-laravel/core rules ===
|
||||
@@ -356,7 +268,7 @@ Route::get('/users', function () {
|
||||
## Do Things the Laravel Way
|
||||
|
||||
- Use `php artisan make:` commands to create new files (i.e. migrations, controllers, models, etc.). You can list available Artisan commands using the `list-artisan-commands` tool.
|
||||
- If you're creating a generic PHP class, use `artisan make:class`.
|
||||
- If you're creating a generic PHP class, use `php artisan make:class`.
|
||||
- Pass `--no-interaction` to all Artisan commands to ensure they work without user input. You should also pass the correct `--options` to ensure correct behavior.
|
||||
|
||||
### Database
|
||||
@@ -391,7 +303,7 @@ Route::get('/users', function () {
|
||||
### Testing
|
||||
- When creating models for tests, use the factories for the models. Check if the factory has custom states that can be used before manually setting up the model.
|
||||
- Faker: Use methods such as `$this->faker->word()` or `fake()->randomDigit()`. Follow existing conventions whether to use `$this->faker` or `fake()`.
|
||||
- When creating tests, make use of `php artisan make:test [options] <name>` to create a feature test, and pass `--unit` to create a unit test. Most tests should be feature tests.
|
||||
- When creating tests, make use of `php artisan make:test [options] {name}` to create a feature test, and pass `--unit` to create a unit test. Most tests should be feature tests.
|
||||
|
||||
### Vite Error
|
||||
- If you receive an "Illuminate\Foundation\ViteException: Unable to locate file in Vite manifest" error, you can run `npm run build` or ask the user to run `npm run dev` or `composer run dev`.
|
||||
@@ -421,6 +333,60 @@ Route::get('/users', function () {
|
||||
- Casts can and likely should be set in a `casts()` method on a model rather than the `$casts` property. Follow existing conventions from other models.
|
||||
|
||||
|
||||
=== wayfinder/core rules ===
|
||||
|
||||
## Laravel Wayfinder
|
||||
|
||||
Wayfinder generates TypeScript functions and types for Laravel controllers and routes which you can import into your client side code. It provides type safety and automatic synchronization between backend routes and frontend code.
|
||||
|
||||
### Development Guidelines
|
||||
- Always use `search-docs` to check wayfinder correct usage before implementing any features.
|
||||
- Always Prefer named imports for tree-shaking (e.g., `import { show } from '@/actions/...'`)
|
||||
- Avoid default controller imports (prevents tree-shaking)
|
||||
- Run `php artisan wayfinder:generate` after route changes if Vite plugin isn't installed
|
||||
|
||||
### Feature Overview
|
||||
- Form Support: Use `.form()` with `--with-form` flag for HTML form attributes — `<form {...store.form()}>` → `action="/posts" method="post"`
|
||||
- HTTP Methods: Call `.get()`, `.post()`, `.patch()`, `.put()`, `.delete()` for specific methods — `show.head(1)` → `{ url: "/posts/1", method: "head" }`
|
||||
- Invokable Controllers: Import and invoke directly as functions. For example, `import StorePost from '@/actions/.../StorePostController'; StorePost()`
|
||||
- Named Routes: Import from `@/routes/` for non-controller routes. For example, `import { show } from '@/routes/post'; show(1)` for route name `post.show`
|
||||
- Parameter Binding: Detects route keys (e.g., `{post:slug}`) and accepts matching object properties — `show("my-post")` or `show({ slug: "my-post" })`
|
||||
- Query Merging: Use `mergeQuery` to merge with `window.location.search`, set values to `null` to remove — `show(1, { mergeQuery: { page: 2, sort: null } })`
|
||||
- Query Parameters: Pass `{ query: {...} }` in options to append params — `show(1, { query: { page: 1 } })` → `"/posts/1?page=1"`
|
||||
- Route Objects: Functions return `{ url, method }` shaped objects — `show(1)` → `{ url: "/posts/1", method: "get" }`
|
||||
- URL Extraction: Use `.url()` to get URL string — `show.url(1)` → `"/posts/1"`
|
||||
|
||||
### Example Usage
|
||||
|
||||
<code-snippet name="Wayfinder Basic Usage" lang="typescript">
|
||||
// Import controller methods (tree-shakable)
|
||||
import { show, store, update } from '@/actions/App/Http/Controllers/PostController'
|
||||
|
||||
// Get route object with URL and method...
|
||||
show(1) // { url: "/posts/1", method: "get" }
|
||||
|
||||
// Get just the URL...
|
||||
show.url(1) // "/posts/1"
|
||||
|
||||
// Use specific HTTP methods...
|
||||
show.get(1) // { url: "/posts/1", method: "get" }
|
||||
show.head(1) // { url: "/posts/1", method: "head" }
|
||||
|
||||
// Import named routes...
|
||||
import { show as postShow } from '@/routes/post' // For route name 'post.show'
|
||||
postShow(1) // { url: "/posts/1", method: "get" }
|
||||
</code-snippet>
|
||||
|
||||
|
||||
### Wayfinder + Inertia
|
||||
If your application uses the `<Form>` component from Inertia, you can use Wayfinder to generate form action and method automatically.
|
||||
<code-snippet name="Wayfinder Form Component (React)" lang="typescript">
|
||||
|
||||
<Form {...store.form()}><input name="title" /></Form>
|
||||
|
||||
</code-snippet>
|
||||
|
||||
|
||||
=== livewire/core rules ===
|
||||
|
||||
## Livewire Core
|
||||
@@ -516,7 +482,7 @@ document.addEventListener('livewire:init', function () {
|
||||
|
||||
## PHPUnit Core
|
||||
|
||||
- This application uses PHPUnit for testing. All tests must be written as PHPUnit classes. Use `php artisan make:test --phpunit <name>` to create a new test.
|
||||
- This application uses PHPUnit for testing. All tests must be written as PHPUnit classes. Use `php artisan make:test --phpunit {name}` to create a new test.
|
||||
- If you see a test using "Pest", convert it to PHPUnit.
|
||||
- Every time a test has been updated, run that singular test.
|
||||
- When the tests relating to your feature are passing, ask the user if they would like to also run the entire test suite to make sure everything is still passing.
|
||||
@@ -613,6 +579,13 @@ export default () => (
|
||||
|
||||
- Always use Tailwind CSS v4 - do not use the deprecated utilities.
|
||||
- `corePlugins` is not supported in Tailwind v4.
|
||||
- In Tailwind v4, configuration is CSS-first using the `@theme` directive — no separate `tailwind.config.js` file is needed.
|
||||
<code-snippet name="Extending Theme in CSS" lang="css">
|
||||
@theme {
|
||||
--color-brand: oklch(0.72 0.11 178);
|
||||
}
|
||||
</code-snippet>
|
||||
|
||||
- In Tailwind v4, you import Tailwind using a regular CSS `@import` statement, not using the `@tailwind` directives used in v3:
|
||||
|
||||
<code-snippet name="Tailwind v4 Import Tailwind Diff" lang="diff">
|
||||
@@ -640,12 +613,4 @@ export default () => (
|
||||
| overflow-ellipsis | text-ellipsis |
|
||||
| decoration-slice | box-decoration-slice |
|
||||
| decoration-clone | box-decoration-clone |
|
||||
|
||||
|
||||
=== tests rules ===
|
||||
|
||||
## Test Enforcement
|
||||
|
||||
- Every change must be programmatically tested. Write a new test or update an existing test, then run the affected tests to make sure they pass.
|
||||
- Run the minimum number of tests needed to ensure code quality and speed. Use `php artisan test` with a specific filename or filter.
|
||||
</laravel-boost-guidelines>
|
||||
|
||||
Reference in New Issue
Block a user