public function __invoke(array $input) { if (!$this->auth->authorizeEndpoint('ShowMyShift')) { return $this->auth->errorPayload; } $my_id = $this->auth->User->id; $my_shift = Shift::where('id', $input['id'])->first(); if ($my_shift->employee_id != $my_id) { return (new Payload())->withStatus(Payload::INVALID)->withOutput($overlapping_shifts->toArray()); } $overlapping_shifts = Shift::shiftsInTimeRange($my_shift->start_time, $my_shift->end_time); $overlapping_shifts = $overlapping_shifts->with('employee')->get(); return (new Payload())->withStatus(Payload::OK)->withOutput(['overlapping_shifts' => $overlapping_shifts->toArray()]); }
public function __invoke(array $input) { if (!$this->auth->authorizeEndpoint('ListMyShifts')) { return $this->auth->errorPayload; } $my_id = $this->auth->User->id; $my_shifts = \ShiftApi\Model\Shift::where('employee_id', $my_id); $my_shifts = $my_shifts->with('manager'); // $my_shifts = $my_shifts->with('overlapping_shifts'); if ($this->helper->checkTrue($input, 'unassigned')) { $my_shifts = $my_shifts->orWhereNull('employee_id'); } $my_shifts = $my_shifts->get(); return (new Payload())->withStatus(Payload::OK)->withOutput($my_shifts->toArray()); }