peltonsolutions / filament-common
A custom package for Filament that provides common enhancements used throughout peltonsolutions packages.
Package info
github.com/peltonsolutions/filament-common
pkg:composer/peltonsolutions/filament-common
Requires
- php: ^8.4
- filament/filament: ^5.0
- laravel/framework: ^11.0|^12.0|^13.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.94
- pestphp/pest: ^2.33
- roave/security-advisories: dev-latest
README
A utility package by Pelton Solutions that provides shared interfaces, models, Filament table columns, form components, and translations used across the Pelton Solutions package ecosystem.
Requirements
- PHP ^8.4
- Laravel ^11.0 | ^12.0 | ^13.0
- Filament ^5.0
Install
composer require peltonsolutions/filament-common
The service provider is auto-discovered and registers the package's translation files automatically.
What's Included
Interfaces
Define contracts your Eloquent models can implement:
| Interface | Method(s) |
|---|---|
HasDateOfBirth |
getDateOfBirth() |
HasEmail |
getEmail() |
HasFilamentUrl |
getFilamentUrl() |
HasName |
getName() |
HasPhoneNumber |
getPhoneNumber() |
HasTenant |
whereTenantUuid(), tenant() |
HasTenantCompany |
company() |
HasTenantGroup |
whereTenantUuid() |
HasTenants |
whereTenantUuid(), tenants() |
HasTimezone |
getTimezone() |
Models
Tenant — Base Eloquent model with UUID primary key (uuid).
PaginatorWithPageInPath — Extends LengthAwarePaginator to embed the page number in the URL path (/items/page/2) instead of a query string parameter.
Filament Table Columns
Pre-configured TextColumn subclasses that format timestamps using the authenticated user's timezone (if they implement HasTimezone) and the active locale:
CreatedAtColumn— sortable, hidden by defaultUpdatedAtColumn— sortable, hidden by defaultDeletedAtColumn— sortable, hidden by default
use PeltonSolutions\FilamentCommon\Filament\Tables\Columns\CreatedAtColumn; use PeltonSolutions\FilamentCommon\Filament\Tables\Columns\UpdatedAtColumn; use PeltonSolutions\FilamentCommon\Filament\Tables\Columns\DeletedAtColumn; // In your Filament resource's table() method: CreatedAtColumn::make(), UpdatedAtColumn::make(), DeletedAtColumn::make(),
Filament Form Components
Pre-configured TextInput subclasses that display read-only timestamp fields on view pages:
CreatedAtView— visible on view pages onlyUpdatedAtView— visible on view pages only
use PeltonSolutions\FilamentCommon\Filament\Forms\Components\CreatedAtView; use PeltonSolutions\FilamentCommon\Filament\Forms\Components\UpdatedAtView; // In your Filament resource's form() method: CreatedAtView::make(), UpdatedAtView::make(),
LinkedFieldView — Abstract TextInput for displaying a related record's name with a link to its Filament view page. Extend it and implement three methods:
use PeltonSolutions\FilamentCommon\Filament\Forms\Components\LinkedFieldView; class UserFieldView extends LinkedFieldView { protected function getRelatedRecord(int|string|null $id): ?Model { return User::find($id); } protected function displayName(Model $relatedRecord): string { return $relatedRecord->name; } protected function getRelatedRecordURL(int|string|null $id): ?string { return UserResource::getUrl('view', ['record' => $id]); } }
Translations
Translations are published under the pelton-solutions-common namespace. Supported locales: en, pt_BR.
Files: buttons, date_formats, fields, notifications, resource.
Testing
composer test
Tests are written with Pest.
Security
If you discover a security vulnerability, please email security@peltonsolutions.com rather than using the issue tracker.
Credits
License
filament-common is open-sourced software licensed under the MIT license.