我用的是Laravel 9。为了澄清我的问题,我将解释模型以及它们之间的关系。
第一个模型是LicenseSubmission
,它与LicenseForm
模型有one to many
关系:
class LicenseSubmission extends Model
{
public function licenseForm(): BelongsTo
{
return $this->belongsTo(LicenseForm::class);
}
}
此外,LicenseForm
模型与Department
模型之间存在one to many
关系:
class LicenseForm extends Model
{
public function department(): BelongsTo
{
return $this->belongsTo(Department::class);
}
}
现在我想得到license_submissions
的命令,由其相关部门的标题。
如何做到这一点?
如果你能回答这个问题,那么Eloquent代码和RawSQL之间没有区别。
1条答案
按热度按时间1u4esq0p1#
试试这个: