<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
novius / laravel-nova-order-nestedset-field example snippets
use Kalnoy\Nestedset\NodeTrait;
use Novius\LaravelNovaOrderNestedsetField\Traits\Orderable;
class Foo extends Model {
use NodeTrait;
use Orderable;
public function getLftName()
{
return 'left';
}
public function getRgtName()
{
return 'right';
}
public function getParentIdName()
{
return 'parent';
}
}
use Novius\LaravelNovaOrderNestedsetField\OrderNestedsetField;
class FooResource extends Resource
{
public function fields(Request $request)
{
return [
OrderNestedsetField::make('Order'),
];
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $orderings
* @return \Illuminate\Database\Eloquent\Builder
*/
protected static function applyOrderings($query, array $orderings)
{
return $query->orderBy('left', 'asc');
}
}
protected function getScopeAttributes()
{
return ['menu_id'];
}
return [
...
'cache_enabled' => true,
];
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Kalnoy\Nestedset\NodeTrait;
use Novius\LaravelNovaOrderNestedsetField\Traits\Orderable;
class Foo extends Model
{
use NodeTrait;
use Orderable;
public static function boot()
{
parent::boot();
if (config('nova-order-nestedset-field.cache_enabled', false)) {
static::created(function (Theme $model) {
$model->clearOrderableCache();
});
static::updated(function (Theme $model) {
$model->clearOrderableCache();
});
static::deleted(function (Theme $model) {
$model->clearOrderableCache();
});
}
}
}
sh
php artisan vendor:publish --provider="Novius\LaravelNovaOrderNestedsetField\OrderNestedsetFieldServiceProvider" --tag="config"
sh
php artisan vendor:publish --provider="Novius\LaravelNovaOrderNestedsetField\OrderNestedsetFieldServiceProvider" --tag="lang"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.