I'm using Laravel 9. To clarify my question I will explain the models also the relations between them.
The first model is LicenseSubmission
which has a one to many
relationship with LicenseForm
model:
class LicenseSubmission extends Model
{
public function licenseForm(): BelongsTo
{
return $this->belongsTo(LicenseForm::class);
}
}
Also, LicenseForm
model has a one to many
relationship with Department
model:
class LicenseForm extends Model
{
public function department(): BelongsTo
{
return $this->belongsTo(Department::class);
}
}
Now I want to get license_submissions
order by its related department's title.
How to do that?
If you can answer this question, there is no difference between Eloquent code and Raw SQL.