parent
							
								
									c8f0fe2d1e
								
							
						
					
					
						commit
						45d0b8f609
					
				
				 4 changed files with 55 additions and 16 deletions
			
			
		@ -0,0 +1,42 @@ | 
				
			|||||||
 | 
					<?php | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Database\Seeders; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Illuminate\Database\Console\Seeds\WithoutModelEvents; | 
				
			||||||
 | 
					use Illuminate\Database\Seeder; | 
				
			||||||
 | 
					use App\Models\Appointment; | 
				
			||||||
 | 
					use Carbon\Carbon; | 
				
			||||||
 | 
					use Carbon\CarbonInterval; | 
				
			||||||
 | 
					use Illuminate\Support\Facades\DB; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AppointmentTableSeeder extends Seeder | 
				
			||||||
 | 
					{ | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * Run the database seeds. | 
				
			||||||
 | 
					     * | 
				
			||||||
 | 
					     * @return void | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    public function run() | 
				
			||||||
 | 
					    { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					         | 
				
			||||||
 | 
					        $startTime = Carbon::parse("09:00:00"); | 
				
			||||||
 | 
					        $endTime = Carbon::parse("17:00:00"); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for ($i = 0; $i < 7; $i++) { | 
				
			||||||
 | 
					            $date = Carbon::now()->addDays($i); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for ($j = 0; $j <= (($endTime->diffInMinutes($startTime)) / 30); $j++) { | 
				
			||||||
 | 
					                $currentTime = $startTime->copy()->addMinutes(30 * $j); | 
				
			||||||
 | 
					                $currentEndTime = $startTime->copy()->addMinutes(30 * $j + 30); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                DB::table('appointments')->insert([ | 
				
			||||||
 | 
					                    'date' => $date, | 
				
			||||||
 | 
					                    'start_time' => $currentTime->format("H:i:s"), | 
				
			||||||
 | 
					                    'end_time' => $currentEndTime->format("H:i:s"), | 
				
			||||||
 | 
					                ]); | 
				
			||||||
 | 
					            } | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					} | 
				
			||||||
									
										Binary file not shown.
									
								
							
						
					Loading…
					
					
				
		Reference in new issue