belongsTo(self::class, 'parent_id'); } public function children() { return $this->hasMany(self::class, 'parent_id'); } public function users() { return $this->belongsToMany(User::class, 'mt_user_skill', 'skill_id', 'user_id') ->withPivot('skill_level') ->withTimestamps(); } public function scopeForBusiness($query, $business_id) { return $query->where('business_id', $business_id); } }