wesselperik / nova-status-field
A Laravel Nova field for displaying statuses.
Installs: 19 723
Dependents: 0
Suggesters: 0
Security: 0
Stars: 14
Watchers: 4
Forks: 2
Open Issues: 1
Language:Vue
Requires
- php: ^8.0
- laravel/nova: ^4.0
README
🚀 Compatible with Laravel Nova 4.0!
A Laravel Nova field for displaying a status icon, with optional tooltip and info text, on index and detail pages of your models. This package utilizes several icons from the Heroicons UI icon pack (from designer Steve Schroger), which is also used in Laravel Nova.
Installation
You can install the package using composer:
composer require wesselperik/nova-status-field
Next up, add the field to your desired Nova model. See the example below:
// for example, in app/Nova/Blog.php use WesselPerik\StatusField\StatusField; // ... public function fields(Request $request) { return [ // Use a single value for tooltips and info... StatusField::make('Published') ->values([ 'inactive' => $this->published == 0, 'pending' => $this->pending == 1 && $this->published == 0, 'active' => $this->pending == 0 && $this->published == 1 ]) ->tooltip($this->status) // optional ->info("Blog status: ".$this->status) // optional ->exceptOnForms() // ...or change text based on the value StatusField::make('Published') ->values([ 'inactive' => $this->published == 0, 'pending' => $this->pending == 1 && $this->published == 0, 'active' => $this->pending == 0 && $this->published == 1 ]) ->tooltip([ 'inactive' => 'Not published', 'pending' => 'Pending publication', 'active' => 'Published' ]) ->info([ 'inactive' => 'This blog is not published yet.', 'pending' => 'This blog is pending publication.', 'active' => 'This blog is published on '.$this->published_at->format('d-m-Y').'.' ]) ->exceptOnForms() ]; }
Available values (with matching icons) are:
- inactive (cross)
- active (checkmark)
- pending (clock)
- info (info icon)
- warning (exclamation mark)
- help (questionmark)
- disabled (minus)
License
The MIT License (MIT). Please see the license file for more information.