Ejemplo n.º 1
0
 /**
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function listSchedule()
 {
     $schedule = Schedule::all();
     $commands = Artisan::all();
     $expressions = ['hourly' => '0 * * * * *', 'daily' => '0 0 * * * *', 'weekly' => '0 0 * * 0 *', 'monthly' => '0 0 1 * * *', 'yearly' => '0 0 1 1 * *', 'every minute' => '* * * * * *', 'every five minutes' => '*/5 * * * * *', 'every ten minutes' => '*/10 * * * * *', 'every thirty minutes' => '0,30 * * * * *'];
     return view('web::configuration.schedule.view', compact('schedule', 'commands', 'expressions'));
 }
Ejemplo n.º 2
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule $schedule
  *
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     // Check that the schedules table exists. This
     // could cause a fatal error if the app is
     // still being setup or the db has not yet
     // been configured. This is a relatively ugly
     // hack as this schedule() method is core to
     // the framework.
     try {
         DB::connection();
         if (!Schema::hasTable('schedules')) {
             throw new Exception('Schema schedules does not exist');
         }
     } catch (Exception $e) {
         return;
     }
     // Load the schedule from the database
     foreach (DBSchedule::all() as $job) {
         $command = $schedule->command($job['command'])->cron($job['expression']);
         // Check if overlapping is allowed
         if (!$job['allow_overlap']) {
             $command = $command->withoutOverlapping();
         }
         // Check if maintenance mode is allowed
         if ($job['allow_maintenance']) {
             $command = $command->evenInMaintenanceMode();
         }
         if ($job['ping_before']) {
             $command = $command->pingBefore($job['ping_before']);
         }
         if ($job['ping_after']) {
             $command->thenPing($job['ping_after']);
         }
     }
 }