public function media()
    {
        $query =  $this->customHasManyThrough('App\Models\Media', 'App\Models\MediaRelation', 'postID', 'mediaID', 'postID', 'mediaID', $this->getTable()."_media");

        if($this->mediaField) {
            $query->where($this->getTable().'_media.field', $this->mediaField);
        }

        // We also need 'field' from media relations, so we can select media based on field name
        $query->select(['media.*',$this->getTable().'_media.field']);

        return $query;
    }
public function media()
    {
        $query =  $this->customHasManyThrough('App\Models\Media', 'App\Models\MediaRelation', 'postID', 'mediaID', 'postID', 'mediaID', $this->getTable()."_media");

        if($this->mediaField) {
            $query->where($this->getTable().'_media.field', $this->mediaField);
        }

        // We also need 'field' from media relations, so we can select media based on field name
        $query->select(['media.*',$this->getTable().'_media.field']);

        return $query;
    }
public function media ( ) { $ query = $ this -> customHasManyThrough ( 'App\Models\Media' , 'App\Models\MediaRelation' , 'postID' , 'mediaID' , 'postID' , 'mediaID' , $ this -> getTable ( ) . "_media" ) ; if ( $ this -> mediaField ) { $ query -> where ( $ this -> getTable ( ) . '_media.field' , $ this -> mediaField ) ; } // We also need 'field' from media relations, so we can select media based on field name $ query -> select ( [ 'media.*' , $ this -> getTable ( ) . '_media.field' ] ) ; return $ query ; }
Media that belong to a Post.

@return HasManyThrough
Media that belong to a Post .