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.
You can install the package using composer:
composer require wesselperik/nova-status-fieldNext 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)
The MIT License (MIT). Please see the license file for more information.
