/**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getOrdersByEmployee(Request $request)
 {
     $resource = new ListResource($this->serializer);
     $totalAmount = function () use($request) {
         $id = (new Orders())->getKeyName();
         return Orders::query()->where('employee_id', '=', $request->employee_id)->get([$id])->count();
     };
     $results = function () use($request) {
         return EloquentHelper::paginate($this->serializer, Orders::query()->where('employee_id', '=', $request->employee_id))->get();
     };
     $uri = route('employees.orders', ['employee_id' => $request->employee_id]);
     return $resource->get($totalAmount, $results, $uri, Orders::class);
 }
 /**
  * @param $id
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getOrdersByEmployee($id)
 {
     $apiRequest = RequestFactory::create();
     $page = $apiRequest->getPage();
     if (!$page->size()) {
         $page->setSize($this->pageSize);
     }
     $fields = $apiRequest->getFields();
     $sorting = $apiRequest->getSort();
     $included = $apiRequest->getIncludedRelationships();
     $filters = $apiRequest->getFilters();
     $resource = new ListResource($this->serializer, $page, $fields, $sorting, $included, $filters);
     $totalAmount = function () use($id) {
         $idKey = (new Orders())->getKeyName();
         return Orders::query()->where('employee_id', '=', $id)->get([$idKey])->count();
     };
     $results = function () use($id) {
         return EloquentHelper::paginate($this->serializer, Orders::query()->where('employee_id', '=', $id))->get();
     };
     $uri = route('employees.orders', ['employee_id' => $id]);
     return $resource->get($totalAmount, $results, $uri, Orders::class);
 }