PHP code example of abordage / nova-table-card

1. Go to this page and download the library: Download abordage/nova-table-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/ */

    

abordage / nova-table-card example snippets




namespace App\Nova\Cards;

use Abordage\TableCard\TableCard;

class MyTableCard extends TableCard
{
    /**
     * Name of the card.
     */
    public string $title = 'My Table Card';

    /**
     * The width of the card (1/2, 1/3, 1/4 or full).
     */
    public $width = '1/3';

    /**
     * Array of table rows
     *
     * Required keys: title, viewUrl
     * Optional keys: subtitle, editUrl
     */
    public function rows(): array
    {
        $rows = [];

        /** for example */
        $models = \App\Models\User::limit(5)->get();
        foreach ($models as $model) {
            $rows[] = [
                'title' => $model->name,
                'subtitle' => $model->email,
                'cssClasses' => ['text-red-500'],
                'viewUrl' => $this->getResourceUrl($model),
                'editUrl' => $this->getResourceUrl($model) . '/edit',
            ];
        }

        return $rows;
    }
}
bash
php artisan nova-table-card MyTableCard