显示类别名称,从一对多显示到

时间:2019-02-15 02:45:03

标签: backpack-for-laravel

I have the following situation: https://www.mindmeister.com/pt/1218233142/category-suppliers

In text:
I have products table wich belongs to many on other table, the other table belongs to one from another table and belongs to one from another table.

This is a system i am developing to multiple users, so has to be this structure...


How can i do something like this?

I already have this structure:

产品负责人

$this->crud->addField([
            'label' => "Categorias",
            'type' => 'select2_multiple',
            'name' => 'Categorias', 
            'entity' => 'Categorias',
            'attribute' => 'nome', //This is not returning the real name, it is returning the name of the CategoriaIntegracaoFornecedor having same id in CategoriaFornecedor and not the related CategoriasFornecedorId :(
            'model' => "App\Models\CategoriasFornecedor", 
            'pivot' => false, 
            'select_all' => true,
    ]);

产品型号

public function Categorias()
{
    return $this->belongsToMany('App\Models\CategoriaIntegracaoFornecedor', 'categorias_produto_integracao_fornecedor_user', 'produto_integracao_fornecedor_user_id');
}

CategoriaIntegracaoFornecedor模型

public function CategoriaFornecedor()
{
    return $this->belongsTo('App\Models\CategoriasFornecedor', 'categoria_fornecedor_id');
}

这个CategoriasFornecedor就是我需要的类别名称...请帮助我吗?

0 个答案:

没有答案