Skip to content

Multiple MorphToMany relationships #197

Discussion options

You must be logged in to vote

Hi @flashmediasolutions,
Combine this package with one of my other ones:
https://github.com/staudenmeir/laravel-merged-relations

  1. Define the relationships:
class Store extends Model
{
    use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
    use \Staudenmeir\LaravelMergedRelations\Eloquent\HasMergedRelationships;

    public function examples()
    {
        return $this->mergedRelationWithModel(Example::class, 'all_examples');
    }

    public function examplesA()
    {
        return $this->hasManyDeepFromRelations($this->sourcesA(), (new SourceA())->examples());
    }

    public function examplesB()
    {
        return $this->hasManyDeepFromRelations($this->sourcesB(), (new So…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@flashmediasolutions
Comment options

Answer selected by flashmediasolutions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants