PHP code example of thijssimonis / nova-list-card

1. Go to this page and download the library: Download thijssimonis/nova-list-card library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

thijssimonis / nova-list-card example snippets




namespace App\Nova\Metrics;

use App\User;
use ThijsSimonis\NovaListCard\NovaListCard;

class LatestUsers extends NovaListCard
{
    public $width = '1/2';

    public function __construct()
    {
        parent::__construct();

        $this->rows(User::select(['id', 'name'])->orderBy('created_at', 'DESC')->limit(5)->get()->map(function ($row) {
            $row['view'] = config('nova.path') . '/resources/users/' . $row['id'];
            return $row;
        })));
    }

    public function uriKey(): string
    {
        return 'latest-users';
    }
}



use App\User;
use ThijsSimonis\NovaListCard\NovaListCard;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    protected function cards(): array
    {
        return [
            (new NovaListCard())
                ->title(__('5 latest users'))
                ->rows(User::select('id', 'name')->orderBy('created_at', 'DESC')->limit(5)->get()),
        ];
    }
}



use App\User;
use ThijsSimonis\NovaListCard\NovaListCard;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    protected function cards(): array
    {
        return [
            (new NovaListCard())
                ->title(__('5 latest users'))
                ->heads([__('ID'), __('Name'))
                ->rows(User::select('id', 'name')->orderBy('created_at', 'DESC')->limit(5)->get()),
        ];
    }
}