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.
		
		
		
		
		
			
		
			
				
					
					
						
							42 lines
						
					
					
						
							1.1 KiB
						
					
					
				
			
		
		
	
	
							42 lines
						
					
					
						
							1.1 KiB
						
					
					
				<?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"),
 | 
						|
                ]);
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 | 
						|
 |