Many To Many Polymorphic Relations: Defining The Inverse Of The Relationship

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Tag extends Model
{
    /**
     * Get all of the posts that are assigned this tag.
     */
    public function posts()
    {
        return $this->morphedByMany('App\Post', 'taggable');
    }

    /**
     * Get all of the videos that are assigned this tag.
     */
    public function videos()
    {
        return $this->morphedByMany('App\Video', 'taggable');
    }
}

Many To Many Polymorphic Relations: Defining The Inverse Of The Relationship — Structure map

Clickable & Draggable!

Many To Many Polymorphic Relations: Defining The Inverse Of The Relationship — Related pages: