diff --git a/resources/lang/en/schedule.php b/resources/lang/en/schedule.php index 6b04f2b..b0fb30d 100644 --- a/resources/lang/en/schedule.php +++ b/resources/lang/en/schedule.php @@ -13,6 +13,7 @@ 'options' => 'Options', 'options_with_value' => 'Options with Value', 'expression' => 'Cron Expression', + 'timezone' => 'Cron timezone', 'log_filename' => 'Log filename', 'output' => 'Output', 'even_in_maintenance_mode' => 'Even in maintenance mode', @@ -39,6 +40,7 @@ 'no-records-found' => 'No records found.', 'save-success' => 'Data saved successfully.', 'save-error' => 'Error saving data.', + 'select-timezone' => 'Select a timezone', 'timezone' => 'All schedules will be executed in the timezone: ', 'select' => 'Select a command', 'custom' => 'Custom Command', diff --git a/resources/lang/pt_BR/schedule.php b/resources/lang/pt_BR/schedule.php index cb95362..9b75448 100644 --- a/resources/lang/pt_BR/schedule.php +++ b/resources/lang/pt_BR/schedule.php @@ -12,6 +12,8 @@ 'options' => 'Opções', 'options_with_value' => 'opções com valor', 'expression' => 'Experessão Cron', + 'select-timezone' => 'Selecione um fuso horário', + 'timezone' => 'Cron fuso horário', 'output' => 'Saída', 'even_in_maintenance_mode' => 'Também em modo de manutenção', 'without_overlapping' => 'Sem sobreposição', diff --git a/resources/views/form.blade.php b/resources/views/form.blade.php index be8e407..f845235 100644 --- a/resources/views/form.blade.php +++ b/resources/views/form.blade.php @@ -2,6 +2,7 @@
- {{ trans('schedule::schedule.messages.timezone') }}{{ config('database-schedule.timezone') }}
+ {{-- {{ trans('schedule::schedule.messages.timezone') }}{{ config('database-schedule.timezone') }} --}}
{{ trans('schedule::schedule.titles.back_to_application') }}
diff --git a/src/Console/Scheduling/Schedule.php b/src/Console/Scheduling/Schedule.php
index d81d9bf..310390c 100644
--- a/src/Console/Scheduling/Schedule.php
+++ b/src/Console/Scheduling/Schedule.php
@@ -5,6 +5,7 @@
use RobersonFaria\DatabaseSchedule\Http\Services\ScheduleService;
use \Illuminate\Console\Scheduling\Schedule as BaseSchedule;
use Illuminate\Support\Facades\Log;
+use Config;
class Schedule
{
@@ -46,7 +47,17 @@ private function dispatch($task)
array_values($task->getArguments()) + $task->getOptions()
);
}
- $event->cron($task->expression);
+ //Setting user timezone
+ if($task->timezone != null){
+ $timezone = $task->timezone;
+ } else {
+ $timezone = config('database-schedule.timezone');
+ }
+ if($timezone == null){
+ $event->cron($task->expression);
+ } else {
+ $event->cron($task->expression)->timezone($timezone);
+ }
//ensure output is being captured to write history
$event->storeOutput();
diff --git a/src/Models/Schedule.php b/src/Models/Schedule.php
index 21c2371..1072670 100644
--- a/src/Models/Schedule.php
+++ b/src/Models/Schedule.php
@@ -48,6 +48,7 @@ class Schedule extends Model
'log_filename',
'groups',
'environments',
+ 'timezone',
];
protected $attributes = [