Пример #1
0
 /**
  * Applies site wide variables to main layout.
  *
  * @param $view
  */
 public function compose(View $view)
 {
     $siteTitle = $this->config->get('site.title.main');
     $currentUser = $this->sentry->getCurrentUser();
     $view->with('siteTitle', $siteTitle);
     $view->with('currentUser', $currentUser);
 }
Пример #2
0
 /**
  * Sends an email to the user with their password reset link.
  */
 public function postRequest()
 {
     if ($this->requestResetValidator->passes()) {
         $user = $this->sentry->findUserByLogin($this->input('email'));
         if ($user) {
             $sent = $this->mail->send('maintenance::emails.reset-password', ['user' => $user, 'code' => $user->getResetPasswordCode()], function ($message) use($user) {
                 $adminEmail = $this->config->get('mail.from.address');
                 $adminName = $this->config->get('mail.from.name');
                 $message->to($user->email, $user->first_name)->from($adminEmail, $adminName)->subject('Reset Your Password');
             });
             if ($sent) {
                 $this->message = "We've sent you an email to reset your password.";
                 $this->messageType = 'success';
                 $this->redirect = route('maintenance.login.forgot-password');
             } else {
                 $this->message = 'There was an issue trying to send your password reset request. Please try again later.';
                 $this->messageType = 'danger';
                 $this->redirect = route('maintenance.login.forgot-password');
             }
         } else {
             $this->message = 'The email/username you entered does not exist, please try again';
             $this->messageType = 'danger';
             $this->redirect = route('maintenance.login.forgot-password');
         }
     } else {
         $this->errors = $this->requestResetValidator->getErrors();
         $this->redirect = route('maintenance.login.forgot-password');
     }
     return $this->response();
 }
Пример #3
0
 /**
  * Creates a work order from the specified work request.
  *
  * @param WorkRequest $workRequest
  *
  * @return WorkOrder|bool
  */
 public function createFromWorkRequest(WorkRequest $workRequest)
 {
     $this->dbStartTransaction();
     /*
      * We'll make sure the work request doesn't already have a
      * work order attached to it before we try and create it
      */
     if (!$workRequest->workOrder) {
         try {
             // Retrieve the default submission status for work orders
             $statusData = $this->config->get('rules.work-requests.submission_status');
             // Create or find the status if it doesn't exist
             $status = $this->status->setInput($statusData)->firstOrCreate();
             // Retrieve the default submission priority for work orders
             $priorityData = $this->config->get('rules.work-requests.submission_priority');
             // Create or find the priority if it doesn't exist
             $priority = $this->priority->setInput($priorityData)->firstOrCreate();
             // Set the work order insert data
             $insert = ['status_id' => $status->id, 'priority_id' => $priority->id, 'request_id' => $workRequest->id, 'user_id' => $workRequest->user_id, 'subject' => $workRequest->subject, 'description' => $workRequest->description];
             // Create the work order
             $workOrder = $this->model->create($insert);
             if ($workOrder) {
                 // Commit the transaction on success
                 $this->dbCommitTransaction();
                 return $workOrder;
             }
         } catch (\Exception $e) {
             $this->dbRollbackTransaction();
         }
     }
     return false;
 }
Пример #4
0
 public function store($asset_id, $meter_id)
 {
     if ($this->meterReadingValidator->passes()) {
         $asset = $this->asset->find($asset_id);
         $meter = $this->meter->find($meter_id);
         $data = $this->inputAll();
         $data['meter_id'] = $meter->id;
         /*
          * Check if duplicate reading entries are enabled
          */
         if ($this->config->get('rules.meters.prevent_duplicate_entries')) {
             /*
              * If the last reading is the same as the reading being inputted
              */
             if ($this->input('reading') === $meter->last_reading) {
                 /*
                  * Return warning message
                  */
                 $this->message = 'Please enter a reading different from the last reading';
                 $this->messageType = 'warning';
                 $this->redirect = route('maintenance.assets.meters.show', [$asset->id, $meter->id]);
                 return $this->response();
             }
         }
         if ($this->meterReading->setInput($data)->create()) {
             $this->message = 'Successfully updated reading';
             $this->messageType = 'success';
             $this->redirect = route('maintenance.assets.show', [$asset->id]);
         } else {
             $this->message = 'There was an error trying to update this meter. Please try again';
             $this->messageType = 'danger';
             $this->redirect = route('maintenance.assets.show', [$asset->id]);
         }
     } else {
         $this->errors = $this->meterReadingValidator->getErrors();
     }
     return $this->response();
 }
Пример #5
0
 /**
  * Retrieves the seed data from the maintenance configuration.
  *
  * @return mixed
  */
 private function getSeedData()
 {
     return $this->config->get('seed.priorities');
 }
Пример #6
0
 /**
  * Returns config option of whether or not sync filters are enabled.
  *
  * @return bool
  */
 private function syncFiltersEnabled()
 {
     return $this->config->get('site.ldap.user_sync.filters.enabled');
 }
 /**
  * @param $view
  */
 public function compose(View $view)
 {
     $siteTitle = $this->config->get('site.title.public', 'Maintenance');
     $view->with('siteTitle', $siteTitle);
 }
Пример #8
0
 /**
  * @param $view
  *
  * @return mixed
  */
 public function compose(View $view)
 {
     /*
      * Stores all the routes for selection, defaults are stored in config
      */
     $allRoutes = $this->config->get('permissions.default');
     /*
      * Get all the routes in the application
      */
     $routes = Route::getRoutes();
     foreach ($routes as $route) {
         $routeName = $route->getName();
         /*
          * Make sure the route has a name
          */
         if ($routeName) {
             /*
              * Get the route filters
              */
             $filters = $route->beforeFilters();
             /*
              * Make sure only routes guarded by the permission filter are shown
              * in the route selection box
              */
             if (array_key_exists('maintenance.permission', $filters)) {
                 /*
                  * Explode the route into segments
                  */
                 $segments = explode('.', $routeName);
                 if (count($segments) >= 1) {
                     /*
                      * Pop the last segment off the route name
                      * so we can append a sentry wildcard to it ('*')
                      */
                     array_pop($segments);
                     /*
                      * Set the array pointer to the last element
                      */
                     end($segments);
                     /*
                      * Add the last element with the wildcard
                      */
                     $segments[] = '*';
                     /*
                      * Implode the array back into dot notation
                      */
                     $routeStar = implode('.', $segments);
                     /*
                      * Insert the route into the allRoutes array
                      */
                     $allRoutes[$segments[0]][$routeStar] = $routeStar;
                 }
                 /*
                  * We'll use the first segment entry to group the routes together
                  * for easier navigation
                  */
                 $allRoutes[$segments[0]][$routeName] = $routeName;
             }
         }
     }
     /*
      * Return the view with the routes for selection
      */
     return $view->with('allRoutes', $allRoutes);
 }
Пример #9
0
 /**
  * Returns the seed data to be inserted into
  * the database.
  *
  * @return array
  */
 public function getSeedData()
 {
     return $this->config->get('permissions', []);
 }
Пример #10
0
 /**
  * Retrieves the seed data from the maintenance configuration.
  *
  * @return mixed
  */
 private function getSeedData()
 {
     return $this->config->get('seed.statuses');
 }
Пример #11
0
 /**
  * Retrieves the seed data from the maintenance configuration.
  *
  * @return mixed
  */
 private function getSeedData()
 {
     return $this->config->get('seed.metrics');
 }