/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $dt = Carbon::createFromDate(2016, 1, 1);
     $rooms = Room::all();
     foreach ($rooms as $room) {
         $timeslots = $room->timeslots()->where('begin', '<=', $dt)->where('end', '>=', $dt)->where('day_id', '=', Carbon::now()->dayOfWeek)->get();
         $this->controlLED($room, $timeslots);
         if (sizeof($timeslots) > 0 && $this->compareTemperatures($room)) {
             $this->startRelay($room);
             continue;
         } else {
             if ($room->heatingsince != null) {
                 $heating = Carbon::createFromFormat('Y-m-d H:i:s', $room->heatingsince);
                 $heating->addMinutes($room->activeduration);
                 if ($heating > Carbon::now() && $this->compareTemperatures($room)) {
                     $this->startRelay($room);
                     continue;
                 } else {
                     $room->heatingsince = null;
                     $room->save();
                 }
             }
         }
         $this->stopRelay($room);
     }
 }
示例#2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($startDate, $endDate)
 {
     $roomAvability = array();
     $roomList = Room::all();
     foreach ($roomList as $room) {
         $roomReservation = DB::table('room')->join('reserved_room', 'room.id', '=', 'reserved_room.room_id')->join('reservation', 'reserved_room.reservation_id', '=', 'reservation.id')->where('room.id', $room->id)->get();
         $currentRoom = array();
         $tempSDate = $startDate;
         while (strtotime($tempSDate) <= strtotime($endDate)) {
             $dayReserved = false;
             foreach ($roomReservation as $ar) {
                 $date_in = strtotime(date('Y-m-d', strtotime($ar->date_in)));
                 if (strtotime($tempSDate) >= $date_in && strtotime($tempSDate) <= strtotime($ar->date_out)) {
                     $temp = clone $ar;
                     $temp->resDay = $this->dayOfReservation($tempSDate, $ar->date_in, $ar->date_out);
                     array_push($currentRoom, $temp);
                     $dayReserved = true;
                     break;
                 }
             }
             if (!$dayReserved) {
                 array_push($currentRoom, 0);
             }
             $tempSDate = date('Y-m-d', strtotime('+1 day', strtotime($tempSDate)));
         }
         array_unshift($currentRoom, $room->number);
         array_push($roomAvability, $currentRoom);
     }
     return response()->json($roomAvability);
 }
 public function listRoomByIcon()
 {
     // hien thi danh sach phong bang icon
     $data['title'] = 'Room Preview';
     $data['room'] = Room::all();
     $data['room_type'] = RoomType::all();
     return view('default/listRoomByIcon', $data);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $timeslots = factory(Timeslot::class)->times(4)->create();
     $rooms = Room::all();
     if (count($rooms) == 0) {
         $rooms = factory(Room::class)->times(4)->create();
     }
     foreach ($timeslots as $timeslot) {
         /** @var Timeslot $timeslot */
         $timeslot->rooms()->sync($rooms->random(2));
     }
 }
 public function index()
 {
     $rooms = Room::all();
     $dir = scandir(public_path() . '/room/');
     $file = array();
     foreach ($dir as $key => $id) {
         if (substr($id, 0, 1) !== ".") {
             $folder = scandir(public_path() . '/room/' . $id . '/');
             $img = array_pop($folder);
             $file += [$id => '/room/' . $id . '/' . $img];
         }
     }
     return view('booking.index', ['rooms' => $rooms, 'file' => $file]);
 }
 /**
  * Check available rooms
  *
  * @return array
  */
 public function checkAvailability(Request $request)
 {
     //add params start_date, end_date
     //Start date_input
     $input = $request->all();
     $currentOccupants = [];
     $rooms = Room::all();
     $check_date = Reservation::whereBetween('start_date', [$input['start_date'], $input['end_date']])->get();
     foreach ($rooms as $index => $room) {
         # code...
         $currentOccupants[$index] = Reservation::where('room_id', $room->id)->where('status', 'accepted')->where('start_date', '<=', [$input['start_date']])->where('end_date', '>=', [$input['end_date']])->count();
     }
     // //EOF date_input
     //display all_table
     $all_table = Room::where('availability', 'vacant')->get();
     // return view('welcome')->with('table',$table);
     return view('welcome')->with(compact('check_date', 'input', 'all_table', 'currentOccupants'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     $currentOccupants = [];
     $rooms = Room::all();
     $reservations_count = Reservation::where('room_id', $input['room_id'])->where('status', 'accepted')->where('start_date', '<=', [$input['start_date']])->where('end_date', '>=', [$input['end_date']])->count();
     $room = Room::find($input['room_id']);
     foreach ($rooms as $index => $roomz) {
         $currentOccupants[$index] = Reservation::where('room_id', $roomz->id)->where('status', 'accepted')->where('start_date', '<=', [$input['start_date']])->where('end_date', '>=', [$input['end_date']])->count();
     }
     $all_table = Room::where('availability', 'vacant')->get();
     if ($reservations_count == $room->pax) {
         return view('reservations.error')->with(compact('input', 'all_table', 'currentOccupants'));
     }
     $person = new Person();
     $person->unique_id = $this->quickRandom();
     $person->first_name = $request->input('first_name');
     $person->last_name = $request->input('last_name');
     $person->address = $request->input('address');
     $person->email = $request->input('email');
     $person->phone = $request->input('phone');
     if ($person->save()) {
         $reservation = new Reservation();
         $reservation->person_id = $person->id;
         $reservation->status = Reservation::STATUS_PENDING;
         $reservation->price = Room::find((int) $request->input('room_id'))->price;
         $reservation->notes = $request->input('notes');
         $reservation->start_date = $request->input('start_date');
         $reservation->end_date = $request->input('end_date');
         $reservation->room_id = (int) $request->input('room_id');
         if ($reservation->save()) {
             return view('reservations.confirmation');
             //TODO redirect to a page with success message
         } else {
             return 'Fail reservation';
             //TODO redirect to a page with error message
         }
     } else {
         return 'Fail Person';
         //TODO redirect to a page with error message
     }
 }
示例#8
0
 public function getAll()
 {
     return Room::all();
 }
 public function index()
 {
     $rooms = Room::all();
     return response()->json($rooms);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $rooms = Room::all();
     return view('rooms.index', compact('rooms'));
 }
示例#11
0
<?php

use App\Http\Controllers\HomeController;
use App\Http\Controllers\RoomsController;
use App\Http\Controllers\TimeslotsController;
use App\Room;
use App\Timeslot;
Route::model('room', 'App\\Room');
Route::get('/', function () {
    return view('welcome');
});
Route::get('/home', HomeController::class . '@index');
Route::get('/week', function () {
    return View::make('control-pages.week', ['rooms' => Room::all()]);
});
Route::resource('room', RoomsController::class);
Route::resource('timeslot', TimeslotsController::class);
Route::get('/api/week', function () {
    return ['Maandag' => Timeslot::where('day_id', '1')->orderBy('begin')->get(), 'Dinsdag' => Timeslot::where('day_id', '2')->orderBy('begin')->get(), 'Woensdag' => Timeslot::where('day_id', '3')->orderBy('begin')->get(), 'Donderdag' => Timeslot::where('day_id', '4')->orderBy('begin')->get(), 'Vrijdag' => Timeslot::where('day_id', '5')->orderBy('begin')->get(), 'Zaterdag' => Timeslot::where('day_id', '6')->orderBy('begin')->get(), 'Zondag' => Timeslot::where('day_id', '7')->orderBy('begin')->get()];
});
Route::get('/api/week/{room}', function (Room $room) {
    $days_list = \App\Day::all();
    $days = [];
    foreach ($days_list as $day) {
        $days[$day->day] = [];
    }
    foreach ($room->timeslots as $timeslot) {
        $days[$timeslot->day->day][] = $timeslot;
    }
    return $days;
});
 /**
  * Show the form for editing the specified resource.
  *
  * @param Timeslot $timeslot
  * @return \Illuminate\Http\Response
  */
 public function edit(Timeslot $timeslot)
 {
     $data = ['days' => Day::all(), 'rooms' => Room::all(), 'timeslot' => $timeslot];
     return view('timeslots.edit', $data);
 }
示例#13
0
 public function index()
 {
     $rooms = Room::all();
     return view('rooms.index')->with('rooms', $rooms);
 }
示例#14
0
 public function index()
 {
     $rooms = Room::all();
     return view('admin.rooms', compact('rooms'));
 }