1. Go to this page and download the library: Download rutorika/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/ */
rutorika / sortable example snippets
// schema builder example
public function up()
{
Schema::create('articles', function (Blueprint $table) {
// ... other fields ...
$table->integer('position'); // Your model must have position field:
});
}
class Article extends Model
{
use \Rutorika\Sortable\SortableTrait;
}
class Article extends Model
{
use \Rutorika\Sortable\SortableTrait;
protected static $sortableField = 'somefield';
}
$entity = Article::find(1);
$positionEntity = Article::find(10)
$entity->moveAfter($positionEntity);
// if $positionEntity->position is 14, then $entity->position is 15 now
'entities' => array(
'articles' => '\App\Article', // entityNameForUseInRequest => ModelName
// or
'articles' => ['entity' => '\App\Article'],
// or for many to many
'posts' => [
'entity' => '\App\Post',
'relation' => 'tags' // relation name (method name which returns $this->belongsToSortedMany)
]
),
$validator = \Validator::make(\Input::all(), array(
'type' => array('ortableEntities))), // entity name, 'articles' in this example
'positionEntityId' => '))), // entity name, 'articles' in this example
'positionEntityId' => '
bash
php artisan vendor:publish
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.