PHP code example of mtsanford / laravel-arrangeable
1. Go to this page and download the library: Download mtsanford/laravel-arrangeable 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/ */
mtsanford / laravel-arrangeable example snippets
use MTSanford\LaravelArrangeable\ArrangeableTrait;
class MyModel extends Model
{
use ArrangeableTrait;
public $arrangeableConfig = [
'foreign_key' => 'foreign_id',
];
}
protected static $arrangeableConfigDefaults = [
'primary_key' => 'id',
'order_key' => 'order',
'foreign_key' => NULL,
'start_order' => 0,
'handle_create' => true,
'handle_delete' => true,
];
// primary_key: primary key of the model
// order_key: the column in the model that holds the order
// foreign_key: order will be maintained with models that have same foreign key
// or in the entire table if NULL.
// start_order value of order_key for the start of the list
// handle_create automatically set order_key on new models to end of list?
// handle_delete automatically maintain order when a model is removed?
class MyModel extends Model
{
use ArrangeableTrait;
public static $arrangeableConfig = [
'foreign_key' => 'parent_id',
'start_order' => 1,
];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.