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.

50 lines
1.7 KiB

  1. <?php
  2. use App\Models\Status;
  3. use App\Models\Workflow;
  4. use Illuminate\Database\Seeder;
  5. use Illuminate\Support\Facades\DB;
  6. class WorkflowSeeder extends Seeder
  7. {
  8. public function run()
  9. {
  10. $workflow_inc = 0;
  11. $status_inc = 0;
  12. $workflows = [];
  13. $statuses = [];
  14. // $status_workflow = [];
  15. for ($business_id=1; $business_id <= 2000; $business_id++) {
  16. $business_workflows = [];
  17. for ($i=0; $i < rand(1, 4); $i++) {
  18. $workflows[] = factory(Workflow::class)->raw([
  19. 'business_id' => $business_id,
  20. ]);
  21. $business_workflows[] = ++$workflow_inc;
  22. for ($i=0; $i < rand(1, 4); $i++) {
  23. $statuses[] = factory(Status::class)->raw([
  24. 'business_id' => $business_id,
  25. 'workflow_id' => $workflow_inc,
  26. ]);
  27. $status_inc++;
  28. }
  29. }
  30. // for ($i=0; $i < rand(1, 4); $i++) {
  31. // $statuses[] = factory(Status::class)->raw([
  32. // 'business_id' => $business_id,
  33. // ]);
  34. // $status_inc++;
  35. // for ($ws=0; $ws < rand(0, count($business_workflows)); $ws++) {
  36. // $status_workflow[] = [
  37. // 'status_id' => $status_inc,
  38. // 'workflow_id' => $business_workflows[rand(0, count($business_workflows)-1)],
  39. // 'order' => rand(0, 10)
  40. // ];
  41. // }
  42. // }
  43. }
  44. DB::table('workflows')->insert($workflows);
  45. DB::table('statuses')->insert($statuses);
  46. // DB::table('status_workflow')->insert($status_workflow);
  47. }
  48. }