Skip to content

Unification of statuses for further use in their packages

License

Notifications You must be signed in to change notification settings

MrVACO/NovaStatusesManager

Repository files navigation

Mr.VACO Statuses Manager

Plugin/Module/Package... Code - Unification of statuses for further use in their packages.

RU readme

Installation

  1. composer require mr-vaco/nova-statuses-manager
  2. php artisan vendor:publish --tag=mr_vaco__statuses
  3. 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),
    ];
}

Statuses Index Statuses Detail Statuses Form Statuses List Index