/** * Get all the courses the are created by the followed user. * * @param $query * @return mixed */ public function scopeFollowedCourses($query) { return $query->join(Course::table(), $this->getFollowedForeignKey(), '=', Course::userForeignKeyName()); }