That sounds like a hasOneThrough relationship :)
https://laravel.com/docs/master/eloquent-relationships#has-one-through
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm not sure what the right term is for this but I have three tables:
Clients is one-to-many on Types Types is one-to-many on IndividualProfiles.
So an IndividualProfile is ultimately only associated with one Client.
Before the Types table didn't exist and this is what was in my IndividualProfilesController:
public function index()
{
$individualprofiles = IndividualProfile::where('client_id', session('client_id'))->get();
return view('individualprofiles.index', ['individualprofiles' => $individualprofiles]);
}
But now I have to use type_id because there is no client_id on the Individual Table. So, my question is, is there an easy way of getting that client_id in Laravel? Or, should I be adding the client_id to my IndividualProfiles table?
That sounds like a hasOneThrough relationship :)
https://laravel.com/docs/master/eloquent-relationships#has-one-through
Please or to participate in this conversation.