musa11971 / nova-status-card

Display a status card on your Laravel Nova dashboard.

Stars
0

Latest version on packagist Total downloads

Display useful status information

This Laravel Nova package allows you to easily display useful status information on your Nova dashboard.

Installation

You can install the package via composer:

composer require musa11971/nova-status-card

Usage

Add the card to your dashboard using NovaServiceProvider.

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    /**
     * Get the cards that should be displayed on the default Nova dashboard.
     *
     * @return array
     */
    protected function cards()
    {
        return [
            NovaStatusCard::make()
                ->title('Server Status')
                ->items([
                    NovaStatusItem::make('Database Usage')
                        ->percentage()
                        ->value(function() {
                            // Calculate value...
                            return 55.43;
                        }),
                        
                    NovaStatusItem::make('Redis Server')
                        ->statusIndicator()
                        ->value(function($value) {
                            // Perform check...
                            return $value->ok();
                        })
                ])
        ];
    }
}

Which produces the following:

Types

There are currently 3 types of status items.

String

NovaStatusItem::make('Department Condition')
    ->string()
    ->value(Department::first()->condition)

Percentage

NovaStatusItem::make('Database Usage')
    ->percentage()
    ->value(function() {
        // Calculate value...
        return 55.43;
    })

Status indicator

NovaStatusItem::make('MySQL Server Status')
    ->statusIndicator()
    ->value(function($value) {
        return $value->ok();
        // or:
        // $value->danger();
        // $value->risky();
        // $value->unknown();
    })

Status indicators also support passing a hint, which will be display as the HTML 'title' attribute. Useful for displaying additional information.

NovaStatusItem::make('MySQL Server Status')
    ->statusIndicator()
    ->value(function($value) {
        return $value->risky()->hint('Server responded slowly.');
    })

Contributing

Pull requests are welcomed.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

Credits go to musa11971 for creating and maintaining the package.

Special thanks

Support me

I am a full-time software engineering student and work on this package in my free time. If you find the package useful, please consider making a donation! Every little bit helps. 💜

License

The MIT License (MIT). Please see License File for more information.