public function search($input)
 {
     $query = ReservedRoomDate::query();
     $columns = Schema::getColumnListing('reservedRoomDates');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
示例#2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     ini_set('memory_limit', '512M');
     $reserveRoom = DB::select('select * from reserve_rooms');
     foreach ($reserveRoom as $rr) {
         $dates = $this->getDates($rr->checkin, $rr->checkout);
         foreach ($dates as $date) {
             if ($date == $rr->checkin) {
                 $modifier = 'i';
             } elseif ($date == $rr->checkout) {
                 $modifier = 'o';
             } else {
                 $modifier = '';
             }
             $data = ['reserve_room_id' => $rr->rr_id, 'room_id' => $rr->room_id, 'status' => $rr->status, 'cal_date' => $date, 'modifier' => $modifier];
             var_dump($data);
             ReservedRoomDate::firstOrCreate($data);
         }
     }
     $this->info("done");
 }