public function Tours() { $SliderImages = SliderImages::all(); $tours = Tours::all(); $country = Country::all(); return View::make('tours.tours')->with('slider', $SliderImages)->with('tours', $tours)->with('country', $country); }
public function editTours($id) { $input_value = array('title' => Input::get('title'), 'description' => Input::get('description'), 'start_date' => Input::get('start_date'), 'end_date' => Input::get('end_date'), 'country' => Input::get('country'), 'city' => Input::get('city'), 'price' => Input::get('price')); $input_check = array('title' => array('required'), 'description' => array('required'), 'start_date' => array('required'), 'end_date' => array('required'), 'country' => array('required'), 'city' => array('required'), 'price' => array('required')); $validator = Validator::make($input_value, $input_check); if ($validator->fails()) { $error = $validator->messages()->toArray(); $tours = Tours::find($id); $country = Country::all(); $city = City::all(); return View::make('admin.tours.tours')->with('tours_edit', $tours)->with('country_edit', $country)->with('city_edit', $city)->with('error_edit', $error); } else { if (!empty(Input::file('image'))) { $tours = Tours::find($id); $img_delete = $tours->img_url; if (file_exists('uploadtours/' . $img_delete)) { unlink('uploadtours/' . $img_delete); } $type = Input::file('image')->getClientOriginalExtension(); $imgName = rand(1111111, 9999999) . time() . "." . $type; $upload = Input::file('image')->move($type, $imgName); if ($upload) { $tours->img_url = $imgName; $tours->title = Input::get('title'); $tours->description = Input::get('description'); $tours->end_date = strtotime(Input::get('end_date')); $tours->start_date = strtotime(Input::get('start_date')); $tours->start_date = date('Y-m-d H:i:s', $tours->start_date); $tours->end_date = date('Y-m-d H:i:s', $tours->end_date); $tours->country = Input::get('country'); $tours->city = Input::get('city'); $tours->price = Input::get('price'); $tours->save(); if ($tours->save()) { $tours = Tours::all(); return View::make('admin.tours.tours')->with('tours_all', $tours)->with('save_edit', ''); } } } else { $tours = Tours::find($id); $tours->title = Input::get('title'); $tours->description = Input::get('description'); $tours->end_date = strtotime(Input::get('end_date')); $tours->start_date = strtotime(Input::get('start_date')); $tours->start_date = date('Y-m-d H:i:s', $tours->start_date); $tours->end_date = date('Y-m-d H:i:s', $tours->end_date); $tours->country = Input::get('country'); $tours->city = Input::get('city'); $tours->price = Input::get('price'); $tours->save(); if ($tours->save()) { $tours = Tours::all(); return View::make('admin.tours.tours')->with('tours_all', $tours)->with('save_edit', ''); } } } }