我使用使用嵌套树的位置并使用“父”字段来选择父位置(我使用重新排序记录创建)。但我需要“父”字段来显示只有父母,只有 parent_id 等于 NULL 的位置。
在位置模型 fields.yaml 我有:
fields:
name:
label: Name
oc.commentPosition: ''
span: left
required: 1
type: text
slug:
label: Slug
oc.commentPosition: ''
span: right
required: 1
preset:
field: name
type: slug
type: text
parent:
label: Parent Location
oc.commentPosition: ''
nameFrom: name
descriptionFrom: description
span: left
type: relation
placeholder: 'select parent location'
description:
label: Description
size: large
oc.commentPosition: ''
span: right
type: textarea
但现在我得到了后端字段“父”的所有位置。有没有办法只获取父位置?
表架构:
参赛作品:
$table->engine = 'InnoDB';
$table->increments('id')->unsigned();
$table->integer('user_id')->nullable()->unsigned();
$table->string('name')->nullable();
$table->string('slug');
$table->text('content')->nullable();
$table->integer('location_id')->nullable();
$table->timestamp('published_at')->nullable();
$table->boolean('published')->default(0);
$table->timestamp('created_at')->nullable();
$table->timestamp('updated_at')->nullable();
地点:
$table->engine = 'InnoDB';
$table->increments('id')->unsigned();
$table->string('name')->nullable();
$table->string('slug')->nullable();
$table->text('description')->nullable();
$table->integer('parent_id')->nullable()->unsigned();
$table->integer('nest_left')->nullable();
$table->integer('nest_right')->nullable();
$table->integer('nest_depth')->nullable();
$table->timestamp('created_at')->nullable();
$table->timestamp('updated_at')->nullable();