public function getIndex() { $key = Input::get('search'); if (isset($key)) { $data = Services::where('name', 'like', '%' . $key . '%')->orderBy('id', 'desc')->paginate(10); } else { $data = Services::orderBy('id', 'desc')->paginate(10); } return View::make('home/dashboard', array())->nest('content', 'services/index', array('data' => $data)); }
public function search() { if (Input::All()) { $book_for = Input::get('book_for'); $book_location = Input::get('book_location'); $book_date = Input::get('book_date'); //match service in services table if this service exist// $services = Services::where('title', 'like', '%' . $book_for . '%')->orWhere('description', 'like', '%' . $book_for . '%')->get(); //match location from venue table who match this service with business id $business_ids = array(); foreach ($services as $key => $val) { $business_ids[] = $val->business_id; } $venueFind = Venue::where('city', 'like', '%' . $book_location . '%')->whereIn('business_id', $business_ids)->get(); $last_query = DB::getQueryLog(); // echo "<pre>";print_r($last_query);die; // return View::make('search.listing')->with('data',$services); $result = array(); foreach ($venueFind as $venue => $venueVal) { $userBookings = $venueVal->business->user_booking(); $last_query = DB::getQueryLog(); //echo "<pre>";print_r($last_query);die; if (isset($userBookings) && count($userBookings) > 0) { //compare date $date1 = date("m-d-Y", strtotime($userBookings->booking_date)); //echo $book_date.'<br>'; //echo $date1.'<br>';die; if (!strtotime($date1) == strtotime($book_date)) { $result[] = $venueVal->business; } } else { //show in listing // echo "<pre>";print_r($venueVal);die; $result[] = $venueVal->business; } } $data['city'] = Venue::get_unique_city(); $data['salon_listing'] = $result; $this->layout->nest('content', 'search.listing', $data); //echo "<pre>";print_r($services);die; //match in user booking table if this service already booked } else { return Redirect::to('/'); } }
public function getService() { $q = Input::get('q'); $data = Services::where('name', 'like', '%' . $q . '%')->orderBy('name', 'asc')->limit(10)->get(); $array = array(); foreach ($data as $row) { $array[] = array('id' => $row->id, 'text' => $row->name . ' - $' . $row->price); } echo json_encode($array); }