jeudi 13 septembre 2018

How to use Laravel's Has Many Through properly

Laravel Eloquent

Good day! I'm having a bit of trouble using Laravel's Eloquent. I'm trying to get all of the organizations a user has through the People model. Every organization has many people and each of the "people" can be associated with a user.

I'd like to be able to call $user->organizations and have it return all of the organizations it's involved in through People.

Tried to follow the official documentation and all I got was a lot of entries in my log file. Many thanks!

Table Structure

Users

  • id
  • first_name
  • last_name

People

  • id
  • first_name
  • last_name
  • user_id
  • organization_id

Organization

  • id
  • name
  • desc


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

Aucun commentaire:

Enregistrer un commentaire