Esempio n. 1
0
 protected function attachTimes($market, $request)
 {
     $date = $market->start_at->toDateString();
     for ($i = 0; $request->days > $i; $i++) {
         if ($i > 0) {
             $date = $market->start_at->addDays($i)->toDateString();
         }
         Time::create(['market_id' => $market->id, 'start' => Carbon::createFromFormat('Y-m-d h:i', $date . ' ' . $request->start_time[$i])->toDateTimeString(), 'end' => Carbon::createFromFormat('Y-m-d h:i', $date . ' ' . $request->end_time[$i])->toDateTimeString()]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $markets = Market::get();
     foreach ($markets as $market) {
         for ($count = 0; $count < 7; $count++) {
             if ($count == 0) {
                 $date = $market->start_at;
             } else {
                 $date = $market->start_at->addDays($count);
             }
             Time::create(['market_id' => $market->id, 'start' => Carbon::now()->setDate($date->year, $date->month, $date->day)->setTime(07, 00, 00)->toDateTimeString(), 'end' => Carbon::now()->setDate($date->year, $date->month, $date->day)->setTime(16, 00, 00)->toDateTimeString()]);
         }
     }
 }