示例#1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $vendedores = Vendedor::with(['cargo', 'funcionario'])->join('funcionarios', 'funcionarios.id', '=', 'vendedores.funcionario_id')->whereHas('funcionario', function ($q) {
         $q->active();
     })->orderBy('funcionarios.filial_id')->orderBy('funcionarios.nome')->get(['vendedores.*']);
     return view('administracao.vendedores.index', compact('vendedores', 'funcionarios'));
 }
 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);
 }