[Vuejs]-How to add my course Slug before lecture in url path?

1👍

You can dynamically grab course slug from the course() relationship defined on the CourseLecture model. See below:

In CourseLecture model:

protected $appends = ['path'];

// relationship
public function course()
{
   return $this->belongsTo(Course::class);
}

public function getPathAttribute()
{
    return "/clientside/instructor/courses/{$this->course->slug}/lectures/$this->slug";
}
👤Zeshan

Leave a comment