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

<?php
use App\Models\Work;
use Illuminate\Database\Seeder;
class WorkSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Work::insert(
factory(Work::class, 2000)->raw()
);
$businessId = 1779;
Work::inRandomOrder()->take(150)->update(['business_id' => $businessId]);
$projects = [3566, 3567, 3568];
foreach ($projects as $projectId) {
Work::where('business_id', $businessId)
->whereNotIn('project_id', $projects)
->take(50)->update(['project_id' => $projectId, 'started_at' => \Carbon\Carbon::now()]);
}
$works = Work::where('business_id', $businessId)->get();
foreach ($works as $work){
\DB::table('works')->where('id', $work->id)
->update(['started_at' => \Carbon\Carbon::now()->subDays(rand(0,90))]);
}
}
}