Esempio n. 1
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     /*
      * Let us know if there is something new :)
      */
     // check if there is a new error
     $schedule->call(function () {
         // get new errors
         $new_errors = Error::cronUnseen()->get();
         if (!$new_errors->isEmpty()) {
             Mail::send('emails.errors', ['errors' => $new_errors], function ($message) {
                 $message->from('*****@*****.**', 'Notification | MyGrades');
                 $message->to("*****@*****.**", $name = null);
                 $message->subject("New errors reported");
             });
             // mark them as seen
             DB::table('errors')->whereNull('cron_seen')->update(['cron_seen' => Carbon::now()]);
         }
     })->hourly();
     // check if there is a new wish
     $schedule->call(function () {
         // get new errors
         $new_wishes = Wish::cronUnseen()->get();
         if (!$new_wishes->isEmpty()) {
             Mail::send('emails.wishes', ['wishes' => $new_wishes], function ($message) {
                 $message->from('*****@*****.**', 'Notification | MyGrades');
                 $message->to("*****@*****.**", $name = null);
                 $message->subject("New wishes");
             });
             // mark them as seen
             DB::table('wishes')->whereNull('cron_seen')->update(['cron_seen' => Carbon::now()]);
         }
     })->hourly();
 }
Esempio n. 2
0
 public function supprimerCategorie()
 {
     if (isset($this->Request->getSuperVars('get')['id'])) {
         // On récupère les variables GET
         $get = $this->Request->getSuperVars('get');
         if ($this->Categories->delete($get['id'])) {
             $this->redirect('/small-mvc-master/blog/accueil/');
         } else {
             Error::throwError('Erreur!', 'Erreur!, Suppression échouée!');
         }
     } else {
         Error::throwError('Erreur!', 'Erreur!, Id de catégorie manquant!');
     }
 }
 /**
  * Saves the editing of errors. An admin can select an error as fixed and/or written.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function updateAdmin()
 {
     foreach (Input::all() as $key => $value) {
         // fixed checked for specific error
         if (starts_with($key, 'fixed') && intval($value) === 1) {
             $error_id = intval(str_replace('fixed', '', $key));
             $error = Error::find($error_id);
             // update error
             $error->fixed = true;
             $error->save();
         } elseif (starts_with($key, 'written') && intval($value) === 1) {
             // written checked for specific error
             $error_id = intval(str_replace('written', '', $key));
             $error = Error::find($error_id);
             // update error
             $error->written = true;
             $error->save();
         }
     }
     // back to form
     return redirect()->route('adminErrors');
 }
Esempio n. 4
0
 */
Router::initialize($_GET);
Session::initialize();
/*
 * On assigne dans des variables :
 * - Le nom de classe du controlleur à instancier
 * - Le chemin de fichier PHP de la classe du controleur
 * - Le nom de la méthode à appeler
 * - Les eventuelles variables passées par URL
 */
$controllerName = Router::getControllerName();
$controllerFilePath = CONTROLLERS_DIR . Router::getControllerFilename();
$methodName = Router::getMethodName();
$args = Router::getArgs();
// On charge le controleur appellé ou celui par défaut
if (file_exists($controllerFilePath)) {
    include_once $controllerFilePath;
    $controllerInstance = new $controllerName();
    // On appelle beforeFilter();
    if (method_exists($controllerInstance, 'beforeFilter')) {
        $controllerInstance->beforeFilter();
    }
    // Si une méthode est définie
    if (method_exists($controllerInstance, $methodName)) {
        $controllerInstance->{$methodName}($args);
    } else {
        Error::throwError('Erreur 404!', 'Erreur 404! : La page demandée est inexistante ou n\'existe plus.');
    }
} else {
    Error::throwError('Erreur 404!', 'Erreur 404! : La page demandée est inexistante ou n\'existe plus.');
}
Esempio n. 5
0
 /**
  * Overwrite response by display pretty view
  *
  * @param string $method
  * @param string $uri
  * @return object response
  */
 public function handle($method = null, $uri = null)
 {
     $di = $this->di;
     $this->di->hook('app.after.handle', function ($response) use($di) {
         // Display pretty view if response is Client/Server Error
         if ($response->isClientError() || $response->isServerError()) {
             $code = $response->getStatus();
             $response->setBody(Error::view($di, $code, $response->getMessage($code)));
         }
     });
     return parent::handle($method, $uri);
 }
 public function error()
 {
     $errors = Error::latest()->get();
     return view('faults.error', ['errors' => $errors]);
 }