PHP code example of codicastudio / mega-filter

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

    

codicastudio / mega-filter example snippets



use DigitalCreative\MegaFilter\MegaFilter;
use DigitalCreative\MegaFilter\HasMegaFilterTrait;
use DigitalCreative\MegaFilter\Column;

class ExampleNovaResource extends Resource {

    use HasMegaFilterTrait; // Important!!

    public function cards(Request $request)
    {
        return [
            MegaFilter::make([
                'filters' => [
                    new DateOfBirthFilter(),
                    new UserTypeFilter()
                ],
                'columns' => [
                    Column::make('Customer Name', 'name')->addFilter(new ActiveFilter()),
                    Column::make('Assets'),
                    Column::make('Payments')
                ]
            ])
        ];
    }

}

use DigitalCreative\MegaFilter\Column;
use DigitalCreative\MegaFilter\HasMegaFilterTrait;
use DigitalCreative\MegaFilter\MegaFilter;

MegaFilter::make([
    'columns' => [
        Column::make($label),
        Column::make($label, $attribute),
        Column::make($label, $attribute, $filters),
        new Column($label, $attribute, $filters),
    ],
])

MegaFilter::make([
    'columns' => [
        Column::make('Gender')->addFilter(new GenderFilter())
    ],
])

MegaFilter::make([
    'columns' => [
        Column::make('Name')->permanent()
    ],
])

MegaFilter::make([
    'columns' => [
        Column::make('Name')->checked() // Checked by default
    ],
])

MegaFilter::make([
    'filters' => [
       new BirthdayFilter(),
       new UserTypeFilter(),
       new GenderFilter(),
    ],
])

MegaFilter::make([
    'actions' => [
       new ExportClientAsExcell(),
    ],
])

public function handle(ActionFields $fields, Collection $models)
{

    $columns = json_decode(request()->input('columns'));

    dd($columns);

}

MegaFilter::make([
    'settings' => [

        /**
         * Tailwind width classes: w-full w-1/2 w-1/3 w-1/4 etc.
         */
        'columnsWidth' => 'w-1/4',
        'filtersWidth' => 'w-1/2',
        
        /**
         * The default state of the main toggle buttons
         */
        'columnsActive' => false,
        'filtersActive' => true,
        'actionsActive' => true,
        
        /**
         * Labels
         */
        'headerLabel' => 'Menu',
        'columnsLabel' => 'Columns',
        'filtersLabel' => 'Filters',
        'actionsLabel' => 'Actions',
        'columnsSectionTitle' => 'Additional Columns',
        'filtersSectionTitle' => 'Filters',
        'actionsSectionTitle' => 'Actions',
        'columnsResetLinkTitle' => 'Reset Columns',
        'filtersResetLinkTitle' => 'Reset Filters',

    ],
])