Пример #1
0
 /**
  * Allows all users to start work order sessions
  * if they don't already have an open session.
  *
  * @param Repository $repository
  *
  * @return bool
  */
 public function authorize(Repository $repository)
 {
     $workOrderId = $this->route('work_orders');
     $session = $repository->findLastUserSession($workOrderId);
     if ($session && $session->out !== null) {
         return false;
     } else {
         return true;
     }
 }
Пример #2
0
 /**
  * Updates a work order session.
  *
  * @param int|string $workOrderId
  *
  * @return bool|WorkOrderSession
  */
 public function update($workOrderId)
 {
     $session = $this->workOrder->findLastUserSession($workOrderId);
     if ($session && $session->user_id === $this->sentry->getCurrentUserId()) {
         $now = Carbon::now()->toDateTimeString();
         $session->out = $now;
         if ($session->save()) {
             return $session;
         }
     }
     return false;
 }