Laravel - Dynamic relationship using hasManyThough() and unique merge
问题 I can think of several ad-hoc ways to do this, but I'm really looking for a 'best practices' type of solution. I have 3 tables involved - users (user_id) - usages ('user_id', 'provider_id', 'nurse_id', 'patient_id') - usage_alerts ('usage_id') Im trying to eager load alerts using hasManyThrough() based on a user's role. The user_id field is agnostic, and can apply to any role, so merging and filtering needs to take place. Using $this->hasManyThrough('UsageAlert', 'Usage')->get() will return a