Edit File: ProviderWorkTimeSeeder.php
<?php namespace Database\Seeders; use App\Models\Provider; use Illuminate\Database\Seeder; use DB; class ProviderWorkTimeSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { // Define the work times for each day $workTimes = [ ['day_id' => 1, 'from' => '09:00:00', 'to' => '19:00:00', 'is_holiday' => 0], ['day_id' => 2, 'from' => '09:00:00', 'to' => '19:00:00', 'is_holiday' => 0], ['day_id' => 3, 'from' => '09:00:00', 'to' => '19:00:00', 'is_holiday' => 0], ['day_id' => 4, 'from' => '09:00:00', 'to' => '19:00:00', 'is_holiday' => 0], ['day_id' => 5, 'from' => '09:00:00', 'to' => '19:00:00', 'is_holiday' => 0], ['day_id' => 6, 'from' => '09:00:00', 'to' => '19:00:00', 'is_holiday' => 0], ['day_id' => 7, 'from' => null, 'to' => null, 'is_holiday' => 1], ]; // Get all providers $providers = Provider::all(); // Adjust if your provider model is located elsewhere foreach ($providers as $provider) { foreach ($workTimes as $workTime) { DB::table('provider_work_times')->updateOrInsert( [ 'provider_id' => $provider->id, 'day_id' => $workTime['day_id'] ], [ 'from' => $workTime['from'] ?? null, 'to' => $workTime['to'] ?? null, 'is_holiday' => $workTime['is_holiday'], 'created_at' => now(), ] ); } } } }
Back to File Manager