On this page
Overview
Chaos does not replace Filament; it gives you shared building blocks. Typical setup:
- Model: use
ChaosModel, timestamps, optional SoftDeletes, and$fillable/$guardedas usual. - Resource: extend
ChaosResourceand add lang entries for titles. - Form: wrap your schema with
ChaosForms::make(). - Table: wrap your columns with
ChaosTables::make(). - Infolist (optional): use
ChaosInfos::make()for view pages. - Pages: extend
ChaosListRecords,ChaosEditRecord,ChaosViewRecordso header actions match registered routes.
ChaosModel trait
Add the trait to any model that should track who created/updated a row.
Behavior
- On create, sets
created_byto the current user id (or0if guest). - On update, sets
updated_bythe same way. - Defines
createdBy()andupdatedBy()asbelongsToApp\Models\User.
Customization
- Override
isUsingActionBy()and returnfalseto hide created-by / updated-by UI fromChaosFormsandChaosTables. - Override
isUsingSoftDelete()if the default detection (trait usesSoftDeletesand notforceDeleting) does not fit.
ChaosResource base class
Extend this instead of Filament\Resources\Resource.
Labels
langFile()takes the resource slug (last segment ofgetSlug()) and uses it as a translation file name.getModelLabel()→__({langFile}.titleSingle)getPluralModelLabel()→__({langFile}.title)
Add a file such as lang/en/posts.php with at least:
1return [2 'title' => 'Posts',3 'titleSingle' => 'Post',4];
Query
- If the model reports
isUsingSoftDelete(), the globalSoftDeletingScopeis removed so you can list and restore trashed records from the same resource. - If
isUsingActionBy()is true,createdByandupdatedByare eager loaded.
ChaosForms::make()
Builds a responsive grid: your fields (span 3 of 4 on sm when the sidebar is visible) plus an optional right column (span 1).
Parameters
Schema $form— the Filament schema instance frompublic static function form(Schema $schema): Schema(pass your$schemathrough).array $schema— components for the main area (sections, fields, etc.).array $sideSections(optional) — extra components above the built-in “record info” block in the sidebar.
Sidebar visibility
The sidebar (including “record info”) shows when:
- you pass non-empty
$sideSections, or - the operation is edit and the model uses timestamps.
Record info includes formatted created_at, updated_at, and a popover on created_by (user card view). The updated_by popover in code is commented out in the package; you can fork or extend if you need it.
Example
1use Filament\Schemas\Components\Section; 2use Filament\Schemas\Schema; 3use LaraZeus\Chaos\Filament\ChaosResource\ChaosForms; 4 5public static function form(Schema $schema): Schema 6{ 7 return ChaosForms::make($schema, [ 8 Section::make() 9 ->columnSpanFull()10 ->schema([11 // … your fields …12 ]),13 ], [14 // optional: extra sidebar sections only15 ]);16}
ChaosTables::make()
Adds standard columns and actions around your own definitions.
Signature
1ChaosTables::make(2 string $resource,3 Table $table,4 array $columns,5 array $actions = [],6 ?array $bulkActions = [],7 array $filters = [],8): Table
$resource: your resource class string (e.g.PostResource::class) so Chaos can readgetModel(),getPages(), and authorization.$columns: your business columns (inserted after the auto ID column).$actions: extra row actions prepended inside the group; View / Edit / Delete / Force delete / Restore are appended when applicable.$bulkActions: passnullto disable all bulk actions; otherwise default bulk delete / force delete / restore are registered.$filters: merged before the Trashed filter (visible only when the model uses soft deletes).
What you get automatically
- ID column (searchable, hidden by default).
created_at,updated_atwhen the model uses timestamps (hidden by default).createdBy.nameandupdatedBy.namepopover columns whenisUsingActionBy()is true.deleted_atwhen soft deletes are enabled.- Row action group with smart visibility (e.g. View only if a
viewpage exists). TrashedFilterwhen soft deletes are enabled.- Pagination: page sizes
[25]. - Default sort: primary key descending.
Example
1use Filament\Tables\Table; 2use LaraZeus\Chaos\Filament\ChaosResource\ChaosTables; 3 4public static function table(Table $table): Table 5{ 6 return ChaosTables::make( 7 static::class, 8 $table, 9 columns: [10 // … your columns …11 ],12 actions: [13 // optional extra row actions14 ],15 bulkActions: [16 // leave default bulk group; use null to disable bulks entirely17 ],18 filters: [19 // your filters20 ],21 );22}
ChaosInfos::make()
For view / infolist Schema: two-column layout with your entries on the left (span 2 of 3) and a record info sidebar (timestamps, created_by / updated_by as HTML strings).
Signature
1ChaosInfos::make(Schema $schema, array $enries): Schema
The second parameter is the array of infolist components for the main column (the parameter name in code is $enries).
Example
1use Filament\Schemas\Schema;2use LaraZeus\Chaos\Filament\ChaosResource\ChaosInfos;3 4public static function infolist(Schema $schema): Schema5{6 return ChaosInfos::make($schema, [7 // … TextEntry::make(...) components for your model …8 ]);9}
Page classes
Replace Filament’s default pages so header actions match registered pages only.
| Class | Extra header actions |
|---|---|
ChaosListRecords |
Create (if create page exists) |
ChaosEditRecord |
View (if view exists), Delete |
ChaosViewRecord |
Edit (if edit exists) |
Register them in your resource’s getPages() as you would with stock Filament pages.
MultiLang form component
Tabs component that builds one tab per locale from config('app.locales'). Each tab stores state under a state path you choose (the string passed to MultiLang::make()).
- The current app locale tab’s field is required; others are not.
- Expects something like
config('app.locales')to be an array of locale keys with at least anamefor the tab label.
Use with Spatie Laravel Translatable (or similar) so the attribute is stored per locale.
Example
1use LaraZeus\Chaos\Forms\Components\MultiLang;2 3MultiLang::make('title')4 ->label(__('Title'));
Ensure config('app.locales') is defined and matches your translatable setup.
UserCardColumn
Extends LaraZeus\Popover\Tables\PopoverColumn. Use it when you want the same popover behavior as Chaos’s user columns but with your own field name or formatting.
Dependencies
Chaos depends on lara-zeus/popover. Install the Filament assets and Tailwind sources for Popover (and Chaos views) as described in Assets.
Zeus is an open-source project. Thanks to my sponsors for helping me maintain this project.