mercredi 9 mai 2018

i want to display a column from 2 tables laravel

i have 2 tables:

teachers and users i want to display for each teacher the name of users who are at the same teacher.

i know in controller maybe it's with inner join:

$users= DB::table('teachers')
->select('name')
->join('users', 'users.id', '=', 'teachers.id')
->get();  

but in blade php i don't know how to display for each teacher, when i do this

<a class="ahref" href=> <div class="blueDecor">

         <p style="text-transform: uppercase;">  </p>

        </div>
    </a>

and when for the :

   @foreach($users as $user)

@endforeach

and here show for all teachers appears all of users

for example Teachers: when i click on Theodor to display Anna, Maria.

Theodor -----------------------> Users: Anna, Maria

Alexander----------------------> Users: Sofia, Alex, Patrick

Sarah--------------------------> Users: Rick, George

please help me:(



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2IlvSxt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire