gpt4 book ai didi

laravel-backpack - laravel-backpack 上的重新排序列是什么?

转载 作者:行者123 更新时间:2023-12-01 11:22:48 26 4
gpt4 key购买 nike

the official documentation , 提到了以下列:

  • parent_id
  • 离开
  • 深度

我没有在文档中找到关于它们类型的任何解释。谁能帮我告诉我它们是什么?

我还想知道如果我只想重新排序项目列表(我不需要任何嵌套),它们是否都是强制性的。

编辑:由于这个问题很受欢迎,我已经updated the documentation with the correct info .

最佳答案

重新排序的 id 列应该是 integer 或 INT(10) 如果你没有使用迁移。

不幸的是,它们都是强制性的,是的。但是如果你在一个非常严格的数据库架构上,你可以通过将这个方法添加到你的 EntityCrudController 来消除除了“lft”列之外的所有它们(基本上覆盖 Backpack\CRUD\app\Http\Controllers\CrudFeatures\Reorder):

public function saveReorder()
{
$this->crud->hasAccessOrFail('reorder');

$all_entries = \Request::input('tree');

if (count($all_entries)) {
$count = 0;

foreach ($all_entries as $key => $entry) {
if ($entry['item_id'] != '' && $entry['item_id'] != null) {
$item = $this->crud->model->find($entry['item_id']);
$item->lft = empty($entry['left']) ? null : $entry['left'];
$item->save();

$count++;
}
}
} else {
return false;
}

return 'success for '.$count.' items';
}

关于laravel-backpack - laravel-backpack 上的重新排序列是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40334901/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com