Level 23
If you set your models right:
http://laravel.com/docs/5.1/eloquent-relationships#many-to-many
then:
$clients=Client::with('users')->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have 3 tables: users, user-to-client, and clients.
In my controller I'm calling all of my clients and I want to return all users related to them as well.
Current code look like this:
$clients = Client::all();
Wasn't quite sure how to call my many-to-many relationship to return the users as well.
Please or to participate in this conversation.