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";
}
Source:stackexchange.com