class Activity extends Model
{
// 定义关联关系
public function adminUsers()
{
// 中间表
$pivotTable = 'activity_admin_users';
// 关联模型类名
$relatedModel = AdminUser::class;
return $this->belongsToMany($relatedModel, $pivotTable, 'activity_id', 'admin_user_id')->withTimestamps();
}
}
$form->multipleSelect('adminUsers')
->options(AdminUser::pluck('username', 'id'))
->customFormat(function ($v) {
// 二维数组转一维 ,主要就是这段
return array_column($v, 'id');
});
标签:conversion,relatedModel,string,关联,报错,multipleSelect,id
From: https://www.cnblogs.com/fengchi/p/18213425