public function edit($id) { $categoriasQuery = Categoria::where('id', '<>', $id)->get(); $categoriasDropDown = ['-1' => 'Selecione a categoria principal'] + $categoriasQuery->lists('nome', 'id')->all(); $categoria = Categoria::findOrNew($id); $tiposCategoria = ['-1' => 'Selecione o tipo da categoria'] + TipoEmpresa::lists('tipo', 'id')->all(); return view('Categoria.Edit')->with('categorias', $categoriasDropDown)->with('categoria', $categoria)->with('tiposCategoria', $tiposCategoria); }
public function destroy($id) { $tipoEmpresa = TipoEmpresa::find($id); if (!empty($tipoEmpresa)) { $tipoEmpresa->delete(); Session::flash('flash_message', 'Tipo Empresa removida com sucesso!'); return redirect()->back(); } $this->errorBag('Tipo Empresa não foi encontrado.'); }
public function create() { $usuarios = Usuario::lists('nome', 'id'); $tiposEmpresas = TipoEmpresa::lists('tipo', 'id'); $planos = Plano::lists('nome', 'id'); $vendedores = Vendedor::all(); $vendedoresSelect = array(); //TODO: Refatorar isso depois foreach ($vendedores as $vendedor) { $vendedoresSelect[$vendedor->id] = Usuario::find($vendedor->idUsuario)->nome; } return view('Empresa.Create')->with('usuarios', $usuarios)->with('tiposEmpresas', $tiposEmpresas)->with('planos', $planos)->with('vendedores', $vendedoresSelect); }
public function store(Request $request) { \App\TipoEmpresa::create(['Tipo' => $request['tipo']]); return "Tipo Empresa Registrada com sucesso!!"; }
public function editar() { $usuario = Auth::User(); $empresa = Empresa::where('idUsuario', '=', $usuario->id)->first(); $tiposEmpresas = ['-1' => 'Selecione o tipo do empreendimento'] + TipoEmpresa::orderBy('tipo', 'asc')->lists('tipo', 'id')->all(); $categorias = ['-1' => 'Selecione a categoria'] + Categoria::orderBy('nome', 'asc')->lists('nome', 'id')->all(); $cartoes = Cartao::orderBy('tipo', 'asc')->get(); $vendedores = ['-1' => 'Selecione o usuário'] + Vendedor::with('Usuario')->get()->lists('Usuario.name', 'id')->all(); $tiposCartoes = ['-1' => 'Selecione o tipo dos cartões'] + TipoCartao::orderBy('descricao', 'asc')->lists('descricao', 'id')->all(); return view('Empresa.Edit')->with('empresa', $empresa)->with('tiposEmpresas', $tiposEmpresas)->with('cartoes', $cartoes)->with('categorias', $categorias)->with('vendedores', $vendedores)->with('tiposCartoes', $tiposCartoes); }