blemli / softrequired-for-filament
Between required and optional lies reality.
Package info
github.com/blemli/softrequired-for-filament
pkg:composer/blemli/softrequired-for-filament
Requires
- php: ^8.2
- filament/filament: ^4.0|^5.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.0
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^3.7|^4.0
- pestphp/pest-plugin-arch: ^3.0|^4.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0
- pestphp/pest-plugin-livewire: ^3.0|^4.0
- rector/rector: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Between required and optional lies reality.
required() doesn't produce data — it produces asdf, test@example.com, and blocked users. Some fields are required by the business but unknowable at entry time. ->softRequired() lets people save and keep working, then tracks what's missing: a warning on the field, a note on save (or a confirm modal), an incomplete() scope, an automatic table filter, and a dashboard completion widget that lists what's missing per record — and lets you complete it right there, in a modal built from your actual form fields. No migrations, no status column — completeness is derived from the data, so it can never lie. And Customer::incomplete() is a machine-readable backlog: hand it to a human — or an AI — to fill the gaps.
Installation
composer require blemli/softrequired-for-filament php artisan softrequired-for-filament:install
Register the plugin in your panel provider: ->plugin(SoftRequiredPlugin::make())
Usage
// Form — declare once, right where required() would go: TextInput::make('email')->softRequired(), TextInput::make('company')->softRequired(warn: false), // counts, but never nags // Model — add the trait; the fields are introspected from your form: use Completable; Customer::incomplete()->count(); // scope, derived from the form $customer->getIncompleteAttributes(); // ['email' => 'Email']
Saving always stays possible: empty soft-required fields show a warning hint, saving pops a warning notification ("Saved — still missing: Email"), the resource table grows an Incomplete filter, and a dashboard widget counts incomplete records until there are none. Prefer asking first? 'on_incomplete_save' => 'confirm' shows a "Save anyway?" modal instead. Ships in English and German.
When NOT to use this
- The whole record may be empty? That's a draft — use a status field.
- The value can be derived? Compute it, don't nag.
- You're marking most of the form? You're modelling a workflow, not completeness.
softRequired() is only for fields that are business-required, unknowable at entry, and suppliable later — by a person, or by an AI working through Model::incomplete().
License
MIT © blemli