/**
  *
  * Predefined Transport List
  *
  */
 public function transportList()
 {
     $vehicle_id = array();
     $vehicles = Vehicle::where('val', 1)->get();
     // filtering
     $vehicle = Vehicle::lists('vehicle_type', 'id');
     $city = array('76' => 'Any') + City::lists('city', 'id');
     //$city['%'] = 'Any';
     if (Session::has('st_date')) {
         $st_date = Session::get('st_date');
     } else {
         $st_date = date("Y/m/d");
     }
     if (Session::has('ed_date')) {
         $ed_date = Session::get('ed_date');
     } else {
         $ed_date = date("Y/m/d", strtotime($st_date . ' + 2 days'));
     }
     if (Input::has('vehicle')) {
         $get_vehicle = Input::get('vehicle');
         $vehicle_id[] = $get_vehicle;
     } else {
         $get_vehicle_ids = Vehicle::select('id')->get();
         foreach ($get_vehicle_ids as $get_vehicle_id) {
             $vehicle_id[] = $get_vehicle_id->id;
         }
     }
     if (Input::has('price_range_transport')) {
         $price_range_array = Input::get('price_range_transport');
         $price_range = explode(';', $price_range_array);
         $min_rate = $price_range[0];
         $max_rate = $price_range[1];
         $min_trans_rate = $min_rate;
         $max_trans_rate = $max_rate;
     } else {
         $min_rate = 0;
         $max_rate = 10000000;
         $min_trans_rate = TransportPackage::min('rate');
         $max_trans_rate = TransportPackage::max('rate');
     }
     if (Input::has('from')) {
         $from = Input::get('from');
     } else {
         $from = '%';
     }
     if (Input::has('from')) {
         $to = Input::get('to');
     } else {
         $to = '%';
     }
     // dd($from.'/'.$to);
     if (Input::has('transport_days')) {
         $days = Input::get('transport_days');
     } else {
         $days = '%';
     }
     //dd($min_rate.'/'.$max_rate);
     $transport_packages = TransportPackage::WhereHas('Vehicle', function ($r) use($vehicle_id) {
         $r->whereIn('id', $vehicle_id);
     })->where('val', 1)->where('rate', '>=', $min_rate)->where('rate', '<=', $max_rate)->where('origin', 'LIKE', $from)->where('destination', 'LIKE', $to)->where('days', 'LIKE', $days)->paginate(9);
     return View::make('transport.transport_list')->with(array('transport_packages' => $transport_packages, 'min_trans_rate' => $min_trans_rate, 'max_trans_rate' => $max_trans_rate, 'vehicle' => $vehicle, 'city' => $city, 'vehicles' => $vehicles, 'st_date' => $st_date, 'ed_date' => $ed_date));
 }
Exemplo n.º 2
0
 /**
  * undocumented function
  *
  * @return void
  * @author 
  **/
 public static function optionsCity()
 {
     return City::lists('name', 'id');
 }
Exemplo n.º 3
0
 public static function listCity()
 {
     $city = City::lists('name', 'id');
     $cityArray = array(['city_id' => 0, 'city_name' => '- Chọn thành phố']);
     if ($city) {
         foreach ($city as $key => $value) {
             $cityArray[] = ['city_id' => $key, 'city_name' => $value];
         }
         return $cityArray;
     }
     return null;
 }
Exemplo n.º 4
0
 /**
  * Show the form for editing the specified country.
  *
  * @param  int  $id
  * @return Response
  */
 public function editAddress($id)
 {
     $address = Address::find($id);
     if (!empty($address)) {
         $countries = array('' => '') + Country::lists('country', 'id');
         $cities = array('' => '') + City::lists('city', 'id');
         // Title
         $title = Lang::get('site/addresses/title.address_update');
         // mode
         $mode = 'edit';
         return View::make('site/addresses/create_edit', compact('title', 'mode', 'countries', 'cities', 'address'));
     } else {
         return Redirect::to('site/addresses')->with('error', Lang::get('site/addresses/messages.does_not_exist'));
     }
 }
Exemplo n.º 5
0
 public static function get_city_array()
 {
     return City::lists('city_name', 'id');
 }