1. Go to this page and download the library: Download leparking/laravel-sortable 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/ */
return [
// Name of the column that will store the position.
'column' => 'position',
// If set to true, new models will be inserted at the first position.
'insert_first' => false,
// A column name or an array of columns names to group sortable models.
'group_by' => false,
];
use Illuminate\Database\Eloquent\Model;
use LeParking\Sortable\Sortable;
use LeParking\Sortable\SortableTrait;
class Book extends Model implements Sortable
{
use SortableTrait;
// Optional property to override default settings.
protected $sortable = [
// ...
];
}