You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an invoice model which is related to another model (addresses) in which the address and name of the person the invoice is sent to are stated. I create an overview and want to sort by a couple of things, such as date, invoice number and name of the addressed person. The relation is defined trough a hasOne function.
I have tried two solutions in which different problems occur
public function nameSortable($query, $direction){
return $query->join('addresses', 'invoices.id', '=', 'addresses.invoice_id')
->orderBy('name', $direction);
}
In this I can sort by anything but it doesnt show the name. When I sort by name the names show up again. A workaround is to print the name differently, namely $invoice->address->name instead of $invoice->name, but than I can't sort by name anymore.
Does anybody know a workaround?
The text was updated successfully, but these errors were encountered:
Hello everybody
I have an invoice model which is related to another model (addresses) in which the address and name of the person the invoice is sent to are stated. I create an overview and want to sort by a couple of things, such as date, invoice number and name of the addressed person. The relation is defined trough a hasOne function.
I have tried two solutions in which different problems occur
option 1 invoicecontroller.php:
In this everyhting except the sorting by name. This does nothing.
Another option is this:
invoicecontroller.php
Invoice.php
In this I can sort by anything but it doesnt show the name. When I sort by name the names show up again. A workaround is to print the name differently, namely $invoice->address->name instead of $invoice->name, but than I can't sort by name anymore.
Does anybody know a workaround?
The text was updated successfully, but these errors were encountered: