I have the following code:
$invoices = \App\Finance_Invoices::query()
->with("file.property")
->where('period', "02")
->where('year', "2022")
->where('paid_to_landlord', 0)
->whereColumn('total_paid', '>=', 'amount')
->whereHas('file.property.landlord', function ($query) use ($id) {
$query->where('id', $id);
})
->orderBy("file.property.full_address")
->get();
The idea is getting the outstanding invoices, but sorted by address. The address is only available through the relation 'file->property'.
With this code I get this error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'file.property.full_address' in 'order clause'