【发布时间】:2023-02-24 21:41:59
【问题描述】:
我有一个有四个关系的模型,如下所示
public function custform_formfields()
{
return $this->hasOne(FormFieldMapping::class,'field_id','field_id');
}
public function custform_fieldtype()
{
return $this->hasOne(FieldType::class, 'fieldtype_id', 'html_field_type');
}
public function custform_forms()
{
return $this->hasOne(CustomForms::class,'form_id', 'form_id');
}
public function custform_options()
{
return $this->hasOne(FormOptions::class,'option_id', 'option_id');
}
$model::with('custform_formfields','custform_fieldtype','custform_forms','custform_options')->whereRelation('custform_formfields',function($q) use ($whereArray) {};
但是,当我使用字段名称 CustomFormsform_name 进行搜索时,出现错误
无法识别多部分标识符。任何想法我都可以使用任何参数进行搜索,包括所有 4 个关系。目前 whereRelation 一次只接受函数。
【问题讨论】:
标签: laravel eloquent laravel-9 eloquent-relationship