PHP code example of think.studio / nova-list-card

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

    

think.studio / nova-list-card example snippets


class FundsWithReportsCount extends ListCard
{
    public function __construct($component = null)
    {
        parent::__construct($component);

        $this->resource(\App\Nova\Resources\Fund::class)
            ->heading($this->name(), 'Reports')
            ->withCount('reports')
            ->orderBy('reports_count', 'desc')
            ->limit(100)
            ->value('reports_count');
    }

    public function cacheFor(): int|Carbon
    {
        return Carbon::now()->addMinutes(2);
    }
}

class FundsWithReportIncomeSum extends ListCard
{
    public function __construct($component = null)
    {
        parent::__construct($component);

        $this->resource(\App\Nova\Resources\Fund::class)
            ->heading($this->name(), 'Total Income')
            ->withSum('reports', 'income')
            ->orderBy('reports_sum_income', 'desc')
            ->limit(100)
            ->value('reports_sum_income');
    }
}

class FundsCustomList extends ListCard
{

    public function __construct($component = null)
    {
        parent::__construct($component);

        $this->resource(\App\Nova\Resources\Fund::class)
            ->heading($this->name())
            ->limit(100)
            ->timestamp('updated_at', 'm/Y')
            ->queryCallback(fn (Builder $q) => $q->where('publication_status', 'draft'));
    }

    public function name(): string
    {
        return 'Draft funds';
    }
}

class FundsWithValueFormat extends ListCard
{
    public function __construct($component = null)
    {
        parent::__construct($component);

        $this->resource(\App\Nova\Resources\Fund::class)
            ->heading($this->name(), 'Created at')
            ->limit(100)
            ->timestamp('updated_at', 'm/Y')
            ->value('created_at', 'datetime', 'm/Y')
            ->classes('bg-yellow-300')
            ->noMaxHeight();
    }
}