PHP code example of alexcrawford / lexorank-sortable
1. Go to this page and download the library: Download alexcrawford/lexorank-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/ */
alexcrawford / lexorank-sortable example snippets
// schema builder example
public function up()
{
Schema::create('articles', function (Blueprint $table) {
// ... other fields ...
$table->string('position'); // Your model must have position field:
});
}
class Article extends Model
{
use \AlexCrawford\Sortable\SortableTrait;
}
class Article extends Model
{
use \AlexCrawford\Sortable\SortableTrait;
protected static $sortableField = 'somefield';
}
$entity = Article::find(1);
$positionEntity = Article::find(10)
$entity->moveAfter($positionEntity);
// if $positionEntity->position is aaa, then $entity->position is aab 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.