Esempio n. 1
0
 public function getNomeIdentificacaoAttribute()
 {
     if ($this->tipoEntidade == "M") {
         $nome = Militar::findOrFail($this->entidade_id);
         return $nome->nome;
     }
     if ($this->tipoEntidade == "C") {
         $nome = Cao::findOrFail($this->entidade_id);
         return $nome->nomeCao;
     }
     if ($this->tipoEntidade == "B") {
         $nome = Entidade::findOrFail($this->entidade_id);
         return $nome->nome;
     }
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     if (User::tipoUserLogado() == 'G' || User::tipoUserLogado() == 'U') {
         echo abort(403, 'Acesso não autorizado');
     }
     $binomio = Binomio::findOrFail($id);
     $listaVertente = VertenteBinomio::all('descricao', 'id');
     $listaUnidades = Unidade::all('descricao', 'id');
     $listaMilitares = Militar::all('nome', 'num_mecanografico', 'id');
     $listaCaes = Cao::all('nomeCao', 'num_matricula', 'id');
     return view('binomios.edit', compact('binomio', 'listaVertente', 'listaUnidades', 'listaMilitares', 'listaCaes'));
 }
 public function goEntidade($id)
 {
     $entidade = Entidade::findOrFail($id);
     $tipoEntidades = $entidade->tipoEntidade;
     switch ($tipoEntidades) {
         case 'M':
             $militar = Militar::findOrFail($id);
             return view('militars.show', compact('militar'));
             break;
         case 'C':
             $cao = Cao::findOrFail($id);
             return view('caos.show', compact('cao'));
             break;
         case 'B':
             $binomio = Binomio::findOrFail($id);
             return view('binomios.show', compact('binomio'));
             break;
         default:
             echo "Tipo de Entidade não Existe!";
             break;
     }
 }
Esempio n. 4
0
 public function getNomeCaoAttribute()
 {
     $nomeCao = Cao::findOrFail($this->cao_id);
     return $nomeCao->nomeCao;
 }
Esempio n. 5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (User::tipoUserLogado() == 'G' || User::tipoUserLogado() == 'U') {
         echo abort(403, 'Acesso não autorizado');
     }
     $a = Cao::findOrFail($id);
     $a->delete();
     return redirect()->route('caos.index')->with('message', 'Item deleted successfully.');
 }
Esempio n. 6
0
 public function getNumIdentificacaoAttribute()
 {
     $num = Cao::findOrFail($this->entidade_id);
     return $num->num_matricula;
 }