1 year ago

Eloquent relationships

Posted 1 year ago by fredmarks

Hi everyone.

I am setting up my table relationships in my models and I have come stuck. Below are my 4 tables


  • id
  • name


  • id
  • title


  • id
  • title


  • user_id
  • assignedtable_id
  • assignedtable_type

I have created my morphMany/morphTo relationships (assigned + project) (assigned + tasks) and that is working fine.

I now want to be able to do get the tasks or projects assigned to a user, by doing this:

  • \App\Models\User::find(1)->tasks
  • \App\Models\User::find(1)->projects

What relationship do I set up to connect [user]->[assigned]->[tasks]

Please sign in or create an account to participate in this conversation.