/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Categorias();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Categorias'])) {
         $model->attributes = $_POST['Categorias'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 2
0
function setCategoria($obj)
{
    $c = new Categorias();
    $c->sku = (string) $obj->codigo;
    $c->nome = (string) $obj->nome;
    $c->parent_sku = (string) $obj->parent;
    $erros = array();
    if (!$c->save()) {
        $erros['codigo_produto'] = $obj->codigo;
        foreach ($user->getMessages() as $message) {
            $erros['mensagem'][] = $message->getMessage();
        }
        return $erros;
    } else {
        return true;
    }
}
 public function postNewCat()
 {
     $dat = Input::all();
     $rules = array('name' => 'required|min:4|max:64', 'type' => 'required');
     $msg = array('name.required' => 'El nombre de la categoria es obligatorio', 'type.required' => 'El tipo es obligatorio', 'min' => 'El nombre de la categoria debe tener un minimo de 4 caracteres', 'max' => 'El nombre de la categoria debe tener un maximo de 64 caracteres');
     $validator = Validator::make($dat, $rules, $msg);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator);
     }
     $nomb = Input::get('name');
     $type = Input::get('type');
     $cat = new Categorias();
     $cat->nombre = $nomb;
     $cat->tipo = $type;
     if ($cat->save()) {
         Session::flash('success', 'Se ha creado la categoria satisfactoriamente.');
         return Redirect::back();
     } else {
         Session::flash('danger', 'Error al guardar la nueva categoria.');
         return Redirect::back();
     }
 }
Ejemplo n.º 4
0
 public function nuevac()
 {
     $categoria = new Categorias();
     $categoria->nombre = Input::get('nombre');
     $categoria->descripcion = Input::get('descripcion');
     $estado = Input::get('estado');
     if ($estado == 1) {
         $categoria->activa = 1;
     } else {
         $categoria->activa = 0;
     }
     $categoria->save();
     return Redirect::to('admin/categorias')->with('message', 'Categoría subida correctamente');
 }