public function AddNewTours()
 {
     $input_value = array('title' => Input::get('title'), 'description' => Input::get('description'), 'country' => Input::get('country'), 'city' => Input::get('city'), 'price' => Input::get('price'), 'start_date' => Input::get('start_date'), 'end_date' => Input::get('end_date'), 'img_url' => Input::file('image'));
     $input_check = array('title' => array('required'), 'description' => array('required'), 'country' => array('required'), 'city' => array('required'), 'price' => array('required'), 'start_date' => array('required'), 'end_date' => array('required'), 'img_url' => array('required', 'mimes:png,jpeg,jpg,gif'));
     $validator = Validator::make($input_value, $input_check);
     if ($validator->fails()) {
         $error = $validator->messages()->toArray();
         echo "<pre>";
         print_r($error);
         echo "</pre>";
     } else {
         $path = 'uploadtours';
         $type = Input::file('image')->getClientOriginalExtension();
         $imageName = rand(1111111, 9999999) . time() . "." . $type;
         $upload = Input::file('image')->move($path, $imageName);
         if ($upload) {
             $tours = new Tours();
             $tours->title = Input::get('title');
             $tours->description = Input::get('description');
             $tours->country = Input::get('country');
             $tours->city = Input::get('city');
             $tours->price = Input::get('price');
             $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->img_url = $imageName;
             $tours->save();
             if ($tours->save()) {
                 $tours = Tours::all();
                 return View::make('admin.tours.tours')->with('tours_all', $tours)->with('save_add_tours', '');
             }
         }
     }
 }
Beispiel #2
0
 /**
  * Checks if a tip has been seen returns false if it has been seen
  * @param  string $key Key to find a tip for
  * @return mixed  Returns false if the tip has been seen, and returns the tip object
  * if it has not been seen yet.
  */
 public static function getTip($key)
 {
     $tip = self::model('Tours')->findByAttributes(array('profileId' => Yii::app()->params->profile->id, 'description' => $key));
     if ($tip && $tip->seen) {
         return false;
     }
     if (empty($tip)) {
         $tip = new Tours();
         $tip->profileId = Yii::app()->params->profile->id;
         $tip->description = $key;
         $tip->save();
     }
     return $tip;
 }