/** * get dispatchedItems. *@param $recipient * @param $level * @return Response */ public function canceledDisItems1($recipient, $level) { if ($level == '1') { $dispatch = RecipientPackageItem::where('recipient_id', $recipient)->where('status', 'canceled')->get()->load('package'); } elseif ($level == '2') { $orgunit = Recipient::find($recipient); $arr = [0, $recipient]; array_push($arr, $recipient); foreach ($orgunit->childrens as $val) { array_push($arr, $val->id); } $dispatch = RecipientPackageItem::where('status', 'canceled')->whereIn('recipient_id', $arr)->get()->load('package'); } elseif ($level == '3') { $orgunit = Recipient::find($recipient); $arr = [0]; array_push($arr, $recipient); foreach ($orgunit->childrens as $val) { array_push($arr, $val->id); $orgunit1 = Recipient::find($val->id); foreach ($orgunit1->childrens as $val) { array_push($arr, $val->id); } } $dispatch = RecipientPackageItem::where('status', 'canceled')->whereIn('recipient_id', $arr)->get()->load('package'); } else { $dispatch = RecipientPackageItem::where('recipient_id', $recipient)->where('status', 'canceled')->get()->load('package'); } return $dispatch; }
/** * Display a expectedPackages items for user. * @TODO Limit the result * @return Response */ public function expectedPackagesItems() { return RecipientPackageItem::where('receiver_id', Auth::user()->recipient_id)->get()->load('recipient', 'vaccine', 'packaging', 'package'); }