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.

51 lines
1.8 KiB

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