Level 75
I suggest get the generated sql and see if it is correct.
1 like
I need to order the query by edtr_item_arrangement from edtrDetails. Is this possible?
$this->getSweeperbookings = OimsTeamRouteAssignmentDetails::
withCount(['EDTRReference'
=> function ($query0) {
$query0->with(['edtrDetails' => function ($query02) {
$query02->with('edtrbook', 'edtrtransaction');
}]);
$query0->whereDate('dispatch_date', Carbon::today());
}])
->with(['EDTRReference'
=> function ($query1) {
$query1->with(['edtrDetails' => function ($query12) {
$query12->with('edtrbook', 'edtrtransaction');
$query12->orderBy('edtr_item_arrangement');
}]);
$query1->withCount(['edtrDetails as pickup' => function ($query11) {
$query11->where('edtr_item_type', 1);
}]);
$query1->withCount(['edtrDetails as delivery' => function ($query11) {
$query11->where('edtr_item_type', 2);
}]);
$query1->whereDate('dispatch_date', Carbon::today());
}])
->where('id', $data['id'])->get();
relationship:
public function EDTRReference()
{
return $this->hasMany(OimsEdtr::class, 'tra_id', 'id');
}
public function edtrDetails()
{
return $this->hasMany(OimsEdtrDetails::class, 'edtr_id', 'id');
}
Please or to participate in this conversation.