mr-vaco / nova-statuses-manager
A Laravel Nova tool - Unification of statuses for further use in their packages
1.0.1
2023-07-19 21:30 UTC
Requires
- php: ^7.4|^8.0
- mr-vaco/nova-panels: ^1.0.3
README
Plugin/Module/Package... Code - Unification of statuses for further use in their packages.
Installation
composer require mr-vaco/nova-statuses-manager
php artisan vendor:publish --tag=mr_vaco__statuses
php artisan migrate
Using
-
StatusClass::LIST('this_code_from_list')
- Getting a list of statuses by "code" sheet parameter - by default: full / base / short -
StatusClass::DEFAULT_ID()
- object - get the first by ID status
StatusClass::DEFAULT_ID()->id StatusClass::DEFAULT_ID()->name StatusClass::DEFAULT_ID()->color
StatusClass::ACTIVE()
- object - get status "active" (default)
StatusClass::ACTIVE()->id StatusClass::ACTIVE()->name StatusClass::ACTIVE()->color
StatusClass::DISABLED()
- object - get "disabled" status (default)
StatusClass::DISABLED()->id StatusClass::DISABLED()->name StatusClass::DISABLED()->color
StatusClass::DRAFT()
- object - get "draft" status (default)
StatusClass::DRAFT()->id StatusClass::DRAFT()->name StatusClass::DRAFT()->color
StatusClass::BY_ID($id)
- object - get status by ID
StatusClass::BY_ID($id)->name StatusClass::BY_ID($id)->color
Use in resources Laravel Nova:
use MrVaco\NovaStatusesManager\Classes\StatusClass; use MrVaco\NovaStatusesManager\Fields\Status; public function fields(NovaRequest $request): array { return [ Status::make(__('Status'), 'status') ->options(StatusClass::LIST('short')) ->default(StatusClass::ACTIVE()->id), ]; }