Php 自我关系(问题)(父类id,多个值错误)

Php 自我关系(问题)(父类id,多个值错误),php,laravel,Php,Laravel,我有下表(类别): 在模型(类别)中: 和在类别(frozennode)中 我在这里试图实现的是让用户能够1。获取父类别名称,以及2。也列出所有没有父id的类别(这意味着它们是父类别) 这是第一步;但我得到了一个错误:多个_值 错误: 在“父类别\u id”中搜索了无效选项“多个\u值”请尝试这样定义两个关系方向: class Category extends ExtendedModel { protected $table = 'categories'; public fun

我有下表(类别):

在模型(类别)中:

和在类别(frozennode)中

我在这里试图实现的是让用户能够1。获取父类别名称,以及2。也列出所有没有父id的类别(这意味着它们是父类别)

这是第一步;但我得到了一个错误:多个_值

错误:
在“父类别\u id”中搜索了无效选项“多个\u值”

请尝试这样定义两个关系方向:

class Category extends ExtendedModel
{
    protected $table = 'categories';

    public function rel_parent_categories()
    {
        return $this->belongsTo('Category', 'parent_category_id');
    }

    public function rel_children_categories()
    {
        return $this->hasMany('Category', 'parent_category_id');
    }
}

如果这不起作用,
ExtendedModel
能做什么?

“在“父类别id”字段中搜索了一个无效选项“多个值”。它所做的只是在我需要时限制一些列,但对该列没有限制。
class Category extends ExtendedModel
{
protected $table = 'categories';

function rel_parent_categories() {
    return $this->belongsTo('Category', 'parent_category_id');
}
}
'edit_fields' => array(
'name',
'parent_category_id' => array(
'title' => 'Parent Category',
'relationship' => 'rel_parent_categories',
'select' => '(:table).name',

),
'active' => array(
'title' => 'Active',
'type' => 'bool',
),
class Category extends ExtendedModel
{
    protected $table = 'categories';

    public function rel_parent_categories()
    {
        return $this->belongsTo('Category', 'parent_category_id');
    }

    public function rel_children_categories()
    {
        return $this->hasMany('Category', 'parent_category_id');
    }
}