public function update($logEntryId)
 {
     $reason = \Request::get('reason');
     if (!in_array($reason, ['training', 'testing'])) {
         throw new \BB\Exceptions\ValidationException("Not a valid reason");
     }
     $equipmentLog = $this->equipmentLogRepository->getById($logEntryId);
     /*
     if ($equipmentLog->user_id == \Auth::user()->id) {
         throw new \BB\Exceptions\ValidationException("You can't update your own record");
     }
     */
     if (!\Auth::user()->hasRole($equipmentLog->device) && !\Auth::user()->isAdmin()) {
         throw new \BB\Exceptions\ValidationException("You don't have permission to alter this record");
     }
     if (!empty($equipmentLog->reason)) {
         throw new \BB\Exceptions\ValidationException("Reason already set");
     }
     $billedStatus = $equipmentLog->billed;
     if ($equipmentLog->billed) {
         //the user has been billed, we need to undo this.
         $payments = $this->paymentRepository->getPaymentsByReference($equipmentLog->id . ':' . $equipmentLog->device);
         if ($payments->count() == 1) {
             $this->paymentRepository->delete($payments->first()->id);
             $billedStatus = false;
         } else {
             throw new \BB\Exceptions\ValidationException("Unable to locate related payment, please contact an admin");
         }
     }
     $this->equipmentLogRepository->update($logEntryId, ['reason' => $reason, 'billed' => $billedStatus]);
     \Notification::success("Record Updated");
     return \Redirect::back();
 }
 /**
  * @return bool
  */
 private function updateLogEntries()
 {
     foreach ($this->logEntries as $entry) {
         //look all the subsequent records for related entries
         //See if there is a record we can join with
         $nextRecord = $this->fetchNextRecord($entry['user_id'], $entry['device'], $entry['reason'], $entry['finished']);
         if ($nextRecord) {
             $this->equipmentLogRepository->update($entry['id'], ['finished' => $nextRecord['finished']]);
             $this->equipmentLogRepository->delete($nextRecord['id']);
             //The array is now dirty - re-fetch it and return to restart the check
             $this->logEntries = $this->equipmentLogRepository->getUnbilledRecords();
             return true;
         }
     }
     return false;
 }