php - Outputting Relation after Select - Eloquent Laravel -


i have laravel application , i've created relationship between 1 table , another.

the relationship hasone on orderdetail model

public function customer() {     return $this->hasone('app\customer', 'cu_acc_code', 'od_account'); } 

i'm performing query on orderdetail

    $orders = orderdetail::where('od_entry_type','s')                         ->where('od_status','0')                         ->where('od_qtyreserved','<>','0')                         ->select(                             db::raw('case when sum(od_qtyord)=sum(od_qtyreserved)then 1 else 0 end fullallocated'),                             'od_order_number',                             db::raw('sum(od_qtyord) ordered'),                             db::raw('sum(od_qtyreserved) allocated')                             )                         ->with(['customer' => function($query) {                             $query->select('cuname');                         }])                         ->groupby('od_order_number')->get();      dd($orders); 

and i'm not getting customer relation?

the result null, know relationship indeed working , there link between two.

any ideas?


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -