Giter Site home page Giter Site logo

nova-card-list's Introduction

Nova Card List

A Laravel Nova card extension from (https://github.com/abordage/nova-table-card)[https://github.com/abordage/nova-table-card] to make listing card for displaying current statistic of grouping.

Requirements

  • PHP 7.4 or higher
  • Nova 4

Installation

You can install the package via composer:

composer require syehan/nova-card-list

Usage

To create a cards use the artisan command:

php artisan nova-card-list MyCardList

By default, all new cards will be placed in the app/Nova/Cards directory. Once your card list class has been generated, you're ready to customize it:

<?php

namespace App\Nova\Cards;

use Syehan\CardList\CardList;

class MyCardList extends CardList
{
    /**
     * Name of the card.
     */
    public string $title = 'My Card List';

    /**
     * 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,
                '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.

Credits

  • Pavel Bychko The man who inspired me to create this extension

nova-card-list's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar syehan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.