diff --git a/app/Http/Controllers/Staff/MassActionController.php b/app/Http/Controllers/Staff/MassActionController.php index 09145dc55c..4cd6e3c7f7 100644 --- a/app/Http/Controllers/Staff/MassActionController.php +++ b/app/Http/Controllers/Staff/MassActionController.php @@ -48,7 +48,12 @@ public function create() */ public function store(Request $request) { - $users = User::all(); + $banned_group = \cache()->rememberForever('banned_group', fn () => Group::where('slug', '=', 'banned')->pluck('id')); + $validating_group = \cache()->rememberForever('validating_group', fn () => Group::where('slug', '=', 'validating')->pluck('id')); + $disabled_group = \cache()->rememberForever('disabled_group', fn () => Group::where('slug', '=', 'disabled')->pluck('id')); + $pruned_group = \cache()->rememberForever('pruned_group', fn () => Group::where('slug', '=', 'pruned')->pluck('id')); + $users = User::whereNotIn('group_id', [$validating_group[0], $banned_group[0], $disabled_group[0], $pruned_group[0]])->pluck('id'); + $subject = $request->input('subject'); $message = $request->input('message'); @@ -61,8 +66,9 @@ public function store(Request $request) return \redirect()->route('staff.mass-pm.create') ->withErrors($v->errors()); } - foreach ($users as $user) { - $this->dispatch(new ProcessMassPM(self::SENDER_ID, $user->id, $subject, $message)); + + foreach ($users as $user_id) { + ProcessMassPM::dispatch(self::SENDER_ID, $user_id, $subject, $message); } return \redirect()->route('staff.mass-pm.create') diff --git a/database/migrations/2020_10_07_012129_create_job_batches_table.php b/database/migrations/2020_10_07_012129_create_job_batches_table.php new file mode 100644 index 0000000000..85ccbf89a7 --- /dev/null +++ b/database/migrations/2020_10_07_012129_create_job_batches_table.php @@ -0,0 +1,39 @@ +string('id')->primary(); + $table->string('name'); + $table->integer('total_jobs'); + $table->integer('pending_jobs'); + $table->integer('failed_jobs'); + $table->text('failed_job_ids'); + $table->text('options')->nullable(); + $table->integer('cancelled_at')->nullable(); + $table->integer('created_at'); + $table->integer('finished_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('job_batches'); + } +}