z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.15k stars 2.82k forks source link

belongsTo 如何传递参数? #5866

Open xiaoyuebao opened 1 month ago

xiaoyuebao commented 1 month ago

Description:

belongsTo 如何传递参数?

$form->belongsTo('author_id', Products::class, '商品'); 我想在Users::class里接收参数,请问如何实现呢

class Products extends Selectable
{
    public $model = Product::class;

    public function make()
    {   
        $this->model()->where('siteId',$siteId)->where('status',1)
                    ->orderby('sort','desc');            
        $this->column('id');
        $this->column('name','商品名称');
        $this->column('unit_price','单价');
        $this->column('cover','商品图片')->image();
        $this->column('created_at');

        $this->filter(function (Filter $filter) {
            $filter->disableIdFilter();
            $filter->like('name');
        });
    }
}