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.

36 lines
959 B

  1. <?php
  2. use App\Models\Work;
  3. use Illuminate\Database\Seeder;
  4. class WorkSeeder extends Seeder
  5. {
  6. /**
  7. * Run the database seeds.
  8. *
  9. * @return void
  10. */
  11. public function run()
  12. {
  13. Work::insert(
  14. factory(Work::class, 2000)->raw()
  15. );
  16. $businessId = 1779;
  17. Work::inRandomOrder()->take(150)->update(['business_id' => $businessId]);
  18. $projects = [3566, 3567, 3568];
  19. foreach ($projects as $projectId) {
  20. Work::where('business_id', $businessId)
  21. ->whereNotIn('project_id', $projects)
  22. ->take(50)->update(['project_id' => $projectId, 'started_at' => \Carbon\Carbon::now()]);
  23. }
  24. $works = Work::where('business_id', $businessId)->get();
  25. foreach ($works as $work){
  26. \DB::table('works')->where('id', $work->id)
  27. ->update(['started_at' => \Carbon\Carbon::now()->subDays(rand(0,90))]);
  28. }
  29. }
  30. }