public function onBooking() { /* * Validate Input */ $rules = ['room_id' => 'required', 'name' => 'required', 'email' => 'required|email|min:2|max:64', 'phone' => 'required', 'persons' => 'required|numeric', 'rooms' => 'required|numeric', 'arrival' => 'required|date', 'departure' => 'required|date', 'pay_plan' => '', 'comment' => '']; $validation = Validator::make(post(), $rules); if ($validation->fails()) { throw new ValidationException($validation); } /* * Record Booking */ $data = Input::all(); $booking = new Booking(); $booking->room_id = $data['room_id']; $booking->full_name = $data['name']; $booking->email = $data['email']; $booking->phone = $data['phone']; $booking->persons = $data['persons']; $booking->rooms = $data['rooms']; $booking->arrival = self::reforgeDate($data['arrival']); $booking->departure = self::reforgeDate($data['departure']); $booking->pay_plan_id = $data['pay_plan']; $booking->comment = $data['comment']; $booking->total_days = $data['total_nights'] + 1; $booking->total_nights = $data['total_nights']; $booking->amount = 0; $booking->currency = ''; $booking->save(); /* * Redirect to the intended page after successful booking */ $redirectUrl = $this->pageUrl($this->property('redirect')); $data = ['subject' => 'Booking notification', 'booking' => $booking]; $email = Settings::get('email_notifications'); if ($email) { Mail::send('tiipiik.booking::mail.send_notification', $data, function ($m) use($email) { $m->to($email); }); } if ($redirectUrl = post('redirect', $redirectUrl)) { return Redirect::intended($redirectUrl); } }
protected function listRooms() { return Room::make()->listFrontEnd(['room' => Settings::get('room_page_slug'), 'perPage' => $this->property('roomsPerPage')]); }
/** * Handler for the pages.menuitem.resolveItem event. * Returns information about a menu item. The result is an array */ public static function resolveMenuItem($item, $url, $theme) { $result = ['items' => []]; $rooms = self::orderBy('name')->get(); $roomPage = Settings::get('roomPage'); foreach ($rooms as $room) { $fullSlug = $roomPage . '/' . $room->slug; $roomItem = ['title' => $room->name, 'url' => Url::action('Cms\\Classes\\Controller@run', ['slug' => $fullSlug]), 'mtime' => $room->updated_at]; $roomItem['isActive'] = $roomItem['url'] == $url; $result['items'][] = $roomItem; } return $result; }