public function vistaEditar($id) { //Me quedo con la categoria, buscando por id //$categoria = Categoria::find($id); $lang = Idioma::where('codigo', App::getLocale())->where('estado', 'A')->first(); $categoria = Categoria::join('categoria_lang', 'categoria_lang.categoria_id', '=', 'categoria.id')->where('categoria_lang.lang_id', $lang->id)->where('categoria_lang.estado', 'A')->where('categoria.id', $id)->first(); $categorias = Categoria::where('estado', 'A')->where('id', '<>', $id)->get(); $this->array_view['categoria'] = $categoria; $this->array_view['categorias'] = $categorias; if ($categoria) { return View::make($this->folder_name . '.editar', $this->array_view); } else { $this->array_view['texto'] = Lang::get('controllers.error_carga_pagina'); return View::make($this->project_name . '-error', $this->array_view); } }
public function lang() { $lang = Idioma::where('codigo', App::getLocale())->where('estado', 'A')->first(); $categoria = Categoria::join('categoria_lang', 'categoria_lang.categoria_id', '=', 'categoria.id')->where('categoria_lang.lang_id', $lang->id)->where('categoria_lang.estado', 'A')->where('categoria.id', $this->id)->first(); if (is_null($categoria)) { echo "Por null"; $lang = Idioma::where('codigo', 'es')->where('estado', 'A')->first(); $categoria = Categoria::join('categoria_lang', 'categoria_lang.categoria_id', '=', 'categoria.id')->where('categoria_lang.lang_id', $lang->id)->where('categoria_lang.estado', 'A')->where('categoria.id', $this->id)->first(); } return $categoria; }