PHP code example of snowrunescape / eloquent-orderable
1. Go to this page and download the library: Download snowrunescape/eloquent-orderable 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/ */
snowrunescape / eloquent-orderable example snippets
use Illuminate\Database\Eloquent\Model;
use SnowRunescape\Orderable\Orderable;
class YourModel extends Model
{
use Orderable;
/**
* The Orderable trait configuration.
*
* @var array
*/
protected $sortable = [
"column_name" => "order",
"sort_direction" => "ASC",
"sort_when_creating" => true,
"apply_global_scope" => true,
"scope_columns" => [],
];
}
$item = YourModel::find(1);
YourModel::updateOrder($item, 2);