Ejemplo n.º 1
0
 /**
  * @param array $input
  * @return PayloadInterface
  */
 public function __invoke(array $input)
 {
     $employee = $this->userRepository->getOneById($input['id']);
     $shifts = $this->shiftRepository->getByEmployee($employee);
     $shiftsCollection = new Collection($shifts, new ShiftTransformer());
     return $this->payload->withStatus(PayloadInterface::OK)->withOutput($this->fractal->createData($shiftsCollection)->toArray());
 }
 public function handle(CreateShift $command)
 {
     $this->shift->setBreak($command->break);
     $this->shift->setEmployee($this->userRepository->getOneById($command->employee_id));
     $this->shift->setManager($this->userRepository->getOneById($command->manager_id));
     $this->shift->setStartTime($command->start_time);
     $this->shift->setEndTime($command->end_time);
     $this->shiftRepository->store($this->shift);
     return $this->shift;
 }
Ejemplo n.º 3
0
 /**
  * @param UserRepository $userRepository
  * @param ShiftRepository $shiftRepository
  * @param Shift $shift
  * @param Guard $auth
  * @return Shift
  */
 public function handle(UserRepository $userRepository, ShiftRepository $shiftRepository, Shift $shift, Guard $auth)
 {
     $shift->setBreak($this->break);
     $shift->setStartTime($this->start_time);
     $shift->setEndTime($this->end_time);
     if ($this->employee_id) {
         $shift->setEmployee($userRepository->getOneById($this->employee_id));
     }
     if ($this->manager_id) {
         $shift->setManager($userRepository->getOneById($this->manager_id));
     } else {
         $shift->setManager($auth->getUser());
     }
     $shiftRepository->store($shift);
     $shiftRepository->update($shift);
     return $shift;
 }
Ejemplo n.º 4
0
 /**
  * Handle domain logic for an action.
  *
  * @param  array $input
  * @return PayloadInterface
  */
 public function __invoke(array $input)
 {
     $user = $this->userRepository->getOneById($input['id']);
     $resource = new Item($user, $this->userTransformer);
     return $this->payload->withStatus(PayloadInterface::OK)->withOutput($this->fractal->createData($resource)->toArray());
 }