From c2ef1d9c741f1424cc52ad1cbbbc6f0902c13665 Mon Sep 17 00:00:00 2001 From: Abhishek Paul Date: Mon, 27 Mar 2023 12:22:37 +0530 Subject: [PATCH 1/3] Fix trashed shedule not showing --- resources/views/form.blade.php | 1 + src/DatabaseSchedulingServiceProvider.php | 4 ++++ src/Http/Controllers/ScheduleController.php | 4 ++-- src/Http/Requests/ScheduleRequest.php | 10 ++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/resources/views/form.blade.php b/resources/views/form.blade.php index be8e407..72a7fef 100644 --- a/resources/views/form.blade.php +++ b/resources/views/form.blade.php @@ -127,6 +127,7 @@ class="form-control @error('command') is-invalid @enderror"> type="text" placeholder="{{ trans('schedule::schedule.messages.custom-command-here')}}" name="command_custom" + value="{{ old('command_custom', $schedule->command_custom ?? '') }}" class="form-control @error('command_custom') is-invalid @enderror"/> @error('command_custom')
{{ $message }}
diff --git a/src/DatabaseSchedulingServiceProvider.php b/src/DatabaseSchedulingServiceProvider.php index 13c862f..92ef2d2 100644 --- a/src/DatabaseSchedulingServiceProvider.php +++ b/src/DatabaseSchedulingServiceProvider.php @@ -72,6 +72,10 @@ public function boot() PhpUnitTestJobCommand::class, ScheduleClearCacheCommand::class, ]); + + Route::bind('schedule', function ($value) { + return \RobersonFaria\DatabaseSchedule\Models\Schedule::withTrashed()->where('id', $value)->firstOrFail(); + }); } protected function registerRoutes() diff --git a/src/Http/Controllers/ScheduleController.php b/src/Http/Controllers/ScheduleController.php index 4d2d2d4..79d838f 100644 --- a/src/Http/Controllers/ScheduleController.php +++ b/src/Http/Controllers/ScheduleController.php @@ -91,7 +91,7 @@ public function store(ScheduleRequest $request) { try { $schedule = app(config('database-schedule.model')); - $schedule->create($request->all()); + $schedule->create($request->validated()); return redirect() ->action('\RobersonFaria\DatabaseSchedule\Http\Controllers\ScheduleController@index') @@ -142,7 +142,7 @@ public function edit(Schedule $schedule) public function update(ScheduleRequest $request, Schedule $schedule) { try { - $schedule->update($request->all()); + $schedule->update($request->validated()); return redirect() ->action('\RobersonFaria\DatabaseSchedule\Http\Controllers\ScheduleController@index') diff --git a/src/Http/Requests/ScheduleRequest.php b/src/Http/Requests/ScheduleRequest.php index 52204d3..384bce5 100644 --- a/src/Http/Requests/ScheduleRequest.php +++ b/src/Http/Requests/ScheduleRequest.php @@ -33,6 +33,16 @@ public function rules() 'log_filename' => 'nullable|alpha_dash', 'groups' => 'nullable|regex:/^[A-Za-z-_0-9,]*$/', 'environments' => 'nullable|regex:/^[A-Za-z-_0-9,]*$/', + 'params' => 'present|array', + 'options' => 'present|array', + 'sendmail_success' => 'present|boolean', + 'sendmail_error' => 'present|boolean', + 'log_success' => 'present|boolean', + 'log_error' => 'present|boolean', + 'even_in_maintenance_mode' => 'present|boolean', + 'without_overlapping' => 'present|boolean', + 'on_one_server' => 'present|boolean', + 'run_in_background' => 'present|boolean' ]; } From e429599425237884190094008f644e0cbfcc0ab0 Mon Sep 17 00:00:00 2001 From: Abhishek Paul Date: Tue, 28 Mar 2023 10:21:38 +0530 Subject: [PATCH 2/3] format code --- src/DatabaseSchedulingServiceProvider.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/DatabaseSchedulingServiceProvider.php b/src/DatabaseSchedulingServiceProvider.php index 92ef2d2..349dd8c 100644 --- a/src/DatabaseSchedulingServiceProvider.php +++ b/src/DatabaseSchedulingServiceProvider.php @@ -13,6 +13,7 @@ use RobersonFaria\DatabaseSchedule\Console\Commands\TestJobCommand; use RobersonFaria\DatabaseSchedule\Console\Commands\ScheduleClearCacheCommand; use RobersonFaria\DatabaseSchedule\Console\Scheduling\Schedule; +use RobersonFaria\DatabaseSchedule\Models\Schedule; class DatabaseSchedulingServiceProvider extends DatabaseScheduleApplicationServiceProvider { @@ -73,9 +74,14 @@ public function boot() ScheduleClearCacheCommand::class, ]); - Route::bind('schedule', function ($value) { - return \RobersonFaria\DatabaseSchedule\Models\Schedule::withTrashed()->where('id', $value)->firstOrFail(); - }); + Route::bind( + 'schedule', + function ($value) { + return Schedule::withTrashed() + ->where('id', $value) + ->firstOrFail(); + } + ); } protected function registerRoutes() From b99220eb780fdd72aa3d74139dd8abdeb50ffeaa Mon Sep 17 00:00:00 2001 From: Abhishek Paul Date: Tue, 28 Mar 2023 10:56:29 +0530 Subject: [PATCH 3/3] fix import --- src/DatabaseSchedulingServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DatabaseSchedulingServiceProvider.php b/src/DatabaseSchedulingServiceProvider.php index 349dd8c..36624c1 100644 --- a/src/DatabaseSchedulingServiceProvider.php +++ b/src/DatabaseSchedulingServiceProvider.php @@ -13,7 +13,7 @@ use RobersonFaria\DatabaseSchedule\Console\Commands\TestJobCommand; use RobersonFaria\DatabaseSchedule\Console\Commands\ScheduleClearCacheCommand; use RobersonFaria\DatabaseSchedule\Console\Scheduling\Schedule; -use RobersonFaria\DatabaseSchedule\Models\Schedule; +use RobersonFaria\DatabaseSchedule\Models\Schedule as ScheduleModel; class DatabaseSchedulingServiceProvider extends DatabaseScheduleApplicationServiceProvider { @@ -77,7 +77,7 @@ public function boot() Route::bind( 'schedule', function ($value) { - return Schedule::withTrashed() + return ScheduleModel::withTrashed() ->where('id', $value) ->firstOrFail(); }