-2
I have my main "home" page with route that is displayed after login.
So this one "home.blade.php" displays a page with the logged in user data.
I created a "dependent" table, I made the relationship between this table and the "users" table, it’s a relationship Onetomany, where a user has "N" dependents.
When logging in I wanted to display a list of dependents and I must be doing wrong.
I have the following function in my controller Homecontroler :
class HomeController extends Controller
{
// OUTRAS FUNÇÕES OMITIDAS
public function home(AQUI COMO COLOCO ID DO USUARIO LOGADO?)
{
$user = User::where('id',$id)-> first();
$dependentes = $user->dependentes()->get();
return view('auth.home');
}
If the above function is correct, how do I put it on the Home page to list dependents? Would that be?
<div class="pmo-block pmo-items hidden-xs">
<h2>Dependentes</h2>
<div class="pmob-body">
@foreach ($dependentes as $dependente)
<div class="row">
<a href="" class="col-xs-2">
<img class="img-circle" src="/bs3/img/demo/profile-pics/1.jpg" alt="">
</a>
</div>
@endforeach
</div>
</div>
Thank you very much, it worked perfectly. Gratitude
– AmandaRJ