Skip to content

Commit

Permalink
coreções no home comtroler e model cidades
Browse files Browse the repository at this point in the history
  • Loading branch information
andersoneves committed Dec 5, 2018
1 parent 593cc6e commit fc2d7af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions app/Http/Controllers/HomeController.php
Expand Up @@ -19,7 +19,9 @@ public function index()
{

$propiedades=Propriedade::all()->where('users_id','=',$this->usuario['cpf']);
$cidade=Cidade::cordenadas($propiedades[0]['cidade_id']);
return view('welcome',["User"=>$this->getFirstName($this->usuario['name']), "Tela"=>"Início",'Longitude'=> $cidade[0]['longitude'],"Latitude" => $cidade[0]['latitude']]);
$propiedade=array_first($propiedades) ;
$cidade=Cidade::cordenadas($propiedade['cidade_id']);

return view('welcome',["User"=>$this->getFirstName($this->usuario['name']), "Tela"=>"Início",'Longitude'=> $cidade['longitude'],"Latitude" => $cidade['latitude']]);
}
}
3 changes: 2 additions & 1 deletion app/Models/Cidade.php
Expand Up @@ -10,6 +10,7 @@ class Cidade extends Model

static function cordenadas($id)
{
return self::all()->where('id','=',$id);
$cidades=self::all()->where('id','=',$id);
return array_first($cidades);
}
}
4 changes: 2 additions & 2 deletions database/seeds/PropriedadeSeeder.php
Expand Up @@ -16,7 +16,7 @@ public function run()
array('users_id' =>'47110931099',
'nome' =>'Fazenda do Tomilho',
'localizacao' =>'Rural',
'cidade_id' =>1),
'cidade_id' =>5129),

array('users_id' =>'47110931099',
'nome' =>'Outra Fazenda do Tomilho',
Expand All @@ -26,7 +26,7 @@ public function run()
array('users_id' =>'47110931099',
'nome' =>'Mais uma do Tomilho',
'localizacao' =>'Pode excluir essa',
'cidade_id' =>1),
'cidade_id' =>5129),

array('users_id' =>'83552301089',
'nome' =>'Cidade de Deus',
Expand Down

0 comments on commit fc2d7af

Please sign in to comment.