client Model
protected $table = 'client';
protected $fillable = [
'client_name',
'supplier_id'
];
public function supplier()
{
return $this->belongsTo(Supplier::class, 'supplier_id', 'id');
}
Supplier table
id | supplier
1 | john
2 | ace
3 | bravo
ClientController
$Client = new Client();
$Client = $Client ->with(
'supplier'
);
$Client = $Client->orderBy('supplier', 'DESC');
Error
Column not found: 1054 Unknown column 'supplier' in 'order clause' (SQL: select * from `client` order by `supplier` desc limit 20 offset 0)
i need to order by supplier from with relationship