PHP code example of elbgoods / laravel-sort-positions-rule

1. Go to this page and download the library: Download elbgoods/laravel-sort-positions-rule 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/ */

    

elbgoods / laravel-sort-positions-rule example snippets


[
    [
        'id' => 1,
        'sort_position' => 1,
        'name' => 'foo'
    ], [
        'id' => 2,
        'sort_position' => 2,
        'name' => 'bar'
    ]
];

use Elbgoods\SortPositionsRule\Rules\SortPositionsRule;

// ...

$rules = [
    // ...
    'array_with_sortable_data' => ['array', new SortPositionsRule('sort_position', 0)],
    // ...
];

bash
php artisan vendor:publish --provider="Elbgoods\SortPositionsRule\SortPositionsRuleServiceProvider" --tag=lang