You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.1 KiB

  1. <?php
  2. use App\Models\Task;
  3. use Illuminate\Database\Seeder;
  4. class TaskTmpSeeder extends Seeder
  5. {
  6. public function run()
  7. {
  8. $systems = \App\Models\System::all();
  9. $tasks = [];
  10. foreach ($systems as $system) {
  11. $status = \App\Models\Status::where('business_id', $system->business_id)->first();
  12. $sprint = \App\Models\Sprint::where('business_id', $system->business_id)->first();
  13. $creator = \App\Models\Business::find($system->business_id)->owners()->first();
  14. array_push($tasks, [
  15. 'title' => \Illuminate\Support\Str::random(5),
  16. 'business_id' => $system->business_id,
  17. 'project_id' => $system->project_id,
  18. 'system_id' => $system->id,
  19. 'workflow_id' => $status->workflow_id,
  20. 'status_id' => $status->id,
  21. 'sprint_id' => $sprint->id ?? null,
  22. 'creator_id' => $creator->id,
  23. ]);
  24. if (sizeof($tasks) == 100) {
  25. Task::insert($tasks);
  26. $tasks = [];
  27. }
  28. }
  29. }
  30. }