PHP code example of spiral / listing

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

    

spiral / listing example snippets


class App extends Core
{
    /**
     * List of classes and bootloaders to be initiated with your application.
     *
     * Attention, bootloader's bindings are compiled and cached, to reload application cache run
     * command "app:reload".
     *
     * @see \Spiral\Core\Bootloaders\Bootloader
     * @var array
     */
    protected $load = [
        // ...
        \Spiral\Listing\Bootloaders\ListingsBootloader::class,
        // ...
    ];
    // ...
}

<dark:use path="spiral:listing/*" prefix="listing:"/>

<script src="webroot/resources/scripts/sf.listing.js"></script> 

 #compile
/** @var \Database\Account $entity */

public function accountsListing(RecordSelector $selector) : Listing
{
    /** @var Listing $listing */
    $listing = $this->factory->make(Listing::class, [
        'selector' => $selector->distinct(),
    ]);

    $listing->addSorter('first_name', new BinarySorter('account.first_name'));
    $listing->addSorter('last_name', new BinarySorter('account.last_name'));

    $listing->addFilter(
        'first_name',
        new SearchFilter(['account.first_name' => SearchFilter::LIKE_STRING])
    );

    $listing->addFilter(
        'last_name',
        new SearchFilter(['account.last_name' => SearchFilter::LIKE_STRING])
    );

    $defaultState = new StaticState('last_name', [], SorterInterface::ASC);

    $listing
        ->setDefaultState($defaultState->withNamespace('accounts'))
        ->setNamespace('accounts');

    return $listing;
}

public function indexAction(AccountsSource $source) : string
{
    $listing = $this->accounts->accountsListing($source->find());

    return $this->views->render('keeper:accounts/list', [
        'listing' => $listing,
    ]);
}
App.php