abordage / nova-table-card
A Laravel Nova card for displaying lists with links to view and edit
Installs: 22 835
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 1
Forks: 5
Open Issues: 1
Requires
- php: >=7.4
- ext-json: *
- laravel/nova: ^4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- nunomaduro/collision: ^5.0 || ^6.0 || ^7.0 || ^8.0
- nunomaduro/larastan: ^1.0 || ^2.0
- orchestra/testbench: ^6.0 || ^7.0 || ^8.0 || ^9.0
- phpunit/phpunit: ^9.6 || ^10.0
This package is auto-updated.
Last update: 2024-12-23 09:46:52 UTC
README
Nova Table Card
A Laravel Nova card for displaying lists with links to view and edit.
Requirements
- PHP 7.4 - 8.3
- Laravel 8.x - 11.x
- Nova 4
Installation
You can install the package via composer:
composer require abordage/nova-table-card
Usage
To create a cards use the artisan
command:
php artisan nova-table-card MyTableCard
By default, all new cards will be placed in the app/Nova/Cards
directory.
Once your table card class has been generated, you're ready to customize it:
<?php 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; } }
Once you have defined a card, you are ready to attach it to a dashboard or resource. You should simply add it to the array of cards.
Feedback
If you have any feedback, comments or suggestions, please feel free to open an issue within this repository.
Credits
License
The MIT License (MIT). Please see License File for more information.