예제 #1
0
 public function index()
 {
     if (Gate::allows('AcessoVendedor')) {
         $usuarioLogado = Auth::User()->load('Vendedor');
         $comerciantes = Comerciante::where('idVendedor', '=', $usuarioLogado->Vendedor->id)->with('Usuario')->with('AssinaturaComerciante')->with('AssinaturaComerciante.Assinatura')->with('AssinaturaComerciante.Assinatura.Plano')->get();
         $vendedores = Vendedor::where('idVendedorPai', '=', $usuarioLogado->Vendedor->id)->with('Usuario')->get();
         return view('Cliente.Gerenciar')->with('comerciantes', $comerciantes);
     }
     return view('401');
 }
예제 #2
0
 public function gravarMetaAdicionada(Request $request, $id)
 {
     if ($request['metas'] == "-1") {
         $request['metas'] = "";
     }
     $regras = array('metas' => 'required');
     $mensagens = array('required' => 'Selecione a meta.');
     $validator = Validator::make($request->all(), $regras, $mensagens);
     if ($validator->fails()) {
         return redirect('Vendedor/VincularMetas/Adicionar/' . $id)->withErrors($validator)->withInput();
     }
     $vendedor = Vendedor::where('idUsuario', '=', $id)->first();
     MetaVendedor::Create(['idMeta' => $request['metas'], 'idVendedor' => $vendedor->id]);
     Session::flash('flash_message', 'Meta vinculada com sucesso!');
     return redirect()->back();
 }