From 99dc9ac65ae614e51dc7cc75c42ccc320fc63be8 Mon Sep 17 00:00:00 2001 From: Nikola Cirkovic Date: Mon, 23 May 2022 21:58:05 +0200 Subject: [PATCH] INA-5 | Add company_id to schedulers so we can fetch them via company_id --- app/Http/Controllers/TaskSchedulerController.php | 4 ++-- app/Models/Scheduler.php | 2 ++ .../migrations/2022_05_18_162443_create_schedulers_table.php | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/TaskSchedulerController.php b/app/Http/Controllers/TaskSchedulerController.php index 42675b7650..f7732a3c59 100644 --- a/app/Http/Controllers/TaskSchedulerController.php +++ b/app/Http/Controllers/TaskSchedulerController.php @@ -49,7 +49,7 @@ class TaskSchedulerController extends BaseController public function index() { - return Scheduler::all(); + return Scheduler::where('company_id', auth()->user()->company()->id)->cursor(); } /** @@ -157,6 +157,7 @@ class TaskSchedulerController extends BaseController { return $scheduler->service()->update($scheduler, $request); } + /** * @OA\PUT( * path="/api/v1/task_scheduler/{scheduler}/update_job/", @@ -192,7 +193,6 @@ class TaskSchedulerController extends BaseController public function updateJob(Scheduler $scheduler, UpdateScheduledJobRequest $request) { return $scheduler->service()->updateJob($scheduler, $request); - } /** diff --git a/app/Models/Scheduler.php b/app/Models/Scheduler.php index 6cc11588bf..ce1939b109 100644 --- a/app/Models/Scheduler.php +++ b/app/Models/Scheduler.php @@ -22,6 +22,7 @@ use Illuminate\Database\Eloquent\Model; * @property string repeat_every * @property \Carbon\Carbon|mixed scheduled_run * @property mixed job + * @property integer company_id */ class Scheduler extends Model { @@ -33,6 +34,7 @@ class Scheduler extends Model 'archived', 'repeat_every', 'scheduled_run', + 'company_id' ]; protected $appends = ['linked_job']; diff --git a/database/migrations/2022_05_18_162443_create_schedulers_table.php b/database/migrations/2022_05_18_162443_create_schedulers_table.php index fbe3ebe6bb..33a5c6ca57 100644 --- a/database/migrations/2022_05_18_162443_create_schedulers_table.php +++ b/database/migrations/2022_05_18_162443_create_schedulers_table.php @@ -29,6 +29,7 @@ class CreateSchedulersTable extends Migration $table->string('repeat_every'); $table->timestamp('start_from'); $table->timestamp('scheduled_run'); + $table->foreignIdFor(\App\Models\Company::class); $table->timestamps(); }); }