<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
maize-tech / laravel-nova-eloquent-sortable example snippets
return [
/*
|--------------------------------------------------------------------------
| See sortable action permission
|--------------------------------------------------------------------------
|
| Here you may specify the fully qualified class name of the invokable class
| used to determine whether a user can see sortable actions or not.
| If null, all users who have access to Nova will have the permission.
|
*/
'can_see_sortable_action' => null,
/*
|--------------------------------------------------------------------------
| Run sortable action permission
|--------------------------------------------------------------------------
|
| Here you may specify the fully qualified class name of the invokable class
| used to determine whether a user can sort a given model or not.
| If null, all users who have access to Nova will have the permission.
|
*/
'can_run_sortable_action' => null,
];
use Laravel\Nova\Resource;
use Maize\NovaEloquentSortable\HasEloquentSortable;
class MyResource extends Resource {
use HasEloquentSortable;
}
use Maize\NovaEloquentSortable\Actions\MoveOrderDownAction;
use Maize\NovaEloquentSortable\Actions\MoveOrderUpAction;
use Maize\NovaEloquentSortable\Actions\MoveToEndAction;
use Maize\NovaEloquentSortable\Actions\MoveToStartAction;
public function actions(NovaRequest $request)
{
return [
MoveOrderDownAction::make(),
MoveToEndAction::make(),
MoveOrderUpAction::make(),
MoveToStartAction::make(),
];
}
use Maize\NovaEloquentSortable\Fields\OrderColumn;
public function fields(NovaRequest $request)
{
return [
OrderColumn::new('Order', static::class),
];
}
use Laravel\Nova\Http\Requests\NovaRequest;
class CanSeeSortableAction
{
public function __invoke(NovaRequest $request): bool
{
return $request->user()->can('sort_models');
}
}
use Illuminate\Database\Eloquent\Model;
use Laravel\Nova\Http\Requests\NovaRequest;
class CanRunSortableAction
{
public function __invoke(NovaRequest $request, Model $model): bool
{
return $request->user()->can('sort_model', $model);
}
}