2 years ago

Eager load relations stored in json field

Posted 2 years ago by christiangerdes


I'm building a notification system using Laravel's notification system where I store the notification in the database with some relevant data. It looks like this:


  • id
  • type
  • notifiable_id
  • notifiable_type
  • data
    • item_id
    • user_id

The data field is json, so my question is how do I eager load the relations? Because i'm using the Notifiable trait, I don't have access to the model...

Hope, that someone can help me. I know, that I could just store the related data directly on the notification, but I want the flexibility of a relation.

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