public function run() { $s = new Slider(); $s->slider_id = 0; $s->active = 1; $s->save(); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Slider(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Slider'])) { $model->attributes = $_POST['Slider']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function store() { if (Input::hasFile('slider')) { $filename = str_random(24) . "." . Input::file('slider')->getClientOriginalExtension(); Input::file('slider')->move(ABS_SLIDER_PATH, $filename); $slider = new SliderModel(); $slider->company_id = Session::get('company_id'); $slider->url = $filename; $slider->save(); $alert['msg'] = 'Slider has been saved successfully'; $alert['type'] = 'success'; return Redirect::route('company.slider')->with('alert', $alert); } else { $alert['msg'] = 'Please select the file to upload'; $alert['type'] = 'danger'; return Redirect::route('company.slider.create')->with('alert', $alert); } }
public function addSLider() { $validator = Validator::make(array('slider' => Input::file("slider")), array('slider' => 'required|image|mimes:jpg,jpeg,png,gif|max:6000'), array('required' => '<span class="glyphicon glyphicon-exclamation-sign"></span> Please insert at least 1 image', 'mimes' => '<span class="glyphicon glyphicon-remove"></span> Unknown file inserted', 'max' => '<span class="glyphicon glyphicon-exclamation-sign"></span> Size must be less than 6 MB')); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } else { $file = Input::file('slider'); $name = date('i-G-Y') . $file->getClientOriginalName(); $destination = 'assets/images/slider/'; $file->move($destination, $name); $query = new Slider(); $query->slider_id = Input::get('getId'); $query->slider_text = Input::get('text'); $query->slider = 'assets/images/slider/' . $name; if ($query->save()) { return Redirect::route('slider-page')->with('event', '<p class="alert alert-success"><span class="glyphicon glyphicon-ok"></span> Slider added successfully</p>'); } else { return Redirect::back()->with('event', '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove> Error occured. Please try after sometime</p></span>'); } } }
public function postSlider($id = '') { $all = Input::all(); $rules = array('name' => 'required|min:2|max:255'); $validator = Validator::make($all, $rules); if ($validator->fails()) { return Redirect::to('/admin/slider/' . $id)->withErrors($validator)->withInput()->with('error', 'Ошибка'); } if (is_numeric($id)) { $post = Slider::find($id); } else { $post = new Slider(); } $post->name = $all['name']; $post->status = isset($all['status']) ? true : false; if (isset($all['image'])) { $full_name = Input::file('image')->getClientOriginalName(); $filename = $full_name; $path = 'upload/slider/'; Input::file('image')->move($path, $filename); $post->image = $path . $filename; } $post->save(); return Redirect::to('/admin/slider/' . $id . '/#preview-slide')->with('success', 'Изменения сохранены'); }
public function insertslider($tid, $vid, $name) { $slider = new Slider(); $slider->name = $name; $slider->t_id = $tid; $slider->v_id = $vid; $slider->save(); return $slider->id; }
/** * * @param $action string * @param $id int * @return nothing * @author Tremor */ public function sliderAction($action, $id = 0) { if (isset($id) && !empty($id) && !is_numeric($id)) { return Redirect::to('admin/slider'); } switch ($action) { case 'add': $slider = new Slider(); $slider->save(); $newId = $slider->id; return Redirect::to('admin/slider/' . $newId); break; case 'edit': $post = Input::except('_token'); $slider = Slider::find($id); foreach ($post as $key => $val) { if (isset($slider->{$key})) { $slider->{$key} = $val; } } $slider->save(); return Redirect::to('admin/slider/' . $id); break; case 'delete': $category = Slider::find($id); $category->delete(); break; default: break; } return Redirect::to('admin/slider'); }
public function actionSlider() { $this->pageTitle = 'Slider'; $SliderAdd = false; $ModelSlider = new Slider(); if (isset($_POST['Slider'])) { $ModelSlider->attributes = $_POST['Slider']; $ImageNewName = date("d-m-Y-H-i-s", time()) . "-slider-" . $ModelSlider->slider_idvideo . '.jpg'; $ImageUrl = 'images/orginal/' . $ImageNewName; $ThumbUrl = 'images/thumbs/' . $ImageNewName; if ($ModelSlider->validate()) { $ModelSlider->ImageCopy($ModelSlider->slider_image, $ImageUrl); $ModelSlider->ImageThumbCreate($ImageUrl, $ThumbUrl); $ModelSlider->slider_image = $ImageUrl; $ModelSlider->slider_thumb = $ThumbUrl; $ModelSlider->save(); $SliderAdd = true; $ModelSlider->slider_idvideo = ''; $ModelSlider->slider_title = ''; $ModelSlider->slider_text = ''; $ModelSlider->slider_image = ''; $ModelSlider->slider_thumb = ''; } } $DataSlider = new CActiveDataProvider('Slider', array('sort' => array('defaultOrder' => 'slider_id DESC'), 'pagination' => array('pageSize' => Yii::app()->params['pageSize'], 'pageVar' => 'page'))); $this->render('slider', array('Data' => $DataSlider, 'SliderAdd' => $SliderAdd, 'ModelSlider' => $ModelSlider)); }
public function saveSlider() { $slider = new Slider(); $slider->save(); }
public function actionAgregarImagenSliderBd() { $slider = new Slider(); $ruta = new Configuracion(); if (isset($_POST['ImagenSlider'])) { //echo "<pre>"; print_r($_FILES); exit(); if ($slider->save()) { $imagen_nombre = 'S-' . str_pad($slider->slider_id, 6, "0", STR_PAD_LEFT) . '-' . str_replace(' ', '_', $_FILES["ImagenSlider"]["name"]['archivo']); $slider->slider_titulo = $_POST['ImagenSlider']['titulo']; $slider->slider_nombre_imagen = $imagen_nombre; if ($slider->save()) { if (move_uploaded_file($_FILES["ImagenSlider"]["tmp_name"]['archivo'], $ruta->findByPk(2)->configuracion_valor . '\\' . $imagen_nombre)) { $this->redirect(array('agregarImagenSlider')); } } } } }