$this->id, "cat_slug"=>Str::slug($this->title)]); //return URL::to('/') . '/e/' . $this->id . '/' . Str::slug($this->title); } public function getTitleAttribute(){ return $this->{'title_'.Config::get('app.locale')}; } /** * The events associated with the category. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function events(){ return $this->hasMany(\App\Models\Event::class); } public function scopeMain($query){ return $query->where('depth',1)->orderBy('lft','asc'); } public function scopeSub($query){ return $query->where('depth',2)->orderBy('lft','asc'); } public function getChildren($parent_id){ return $this->where('parent_id',$parent_id)->orderBy('lft','asc'); } public function parent(){ return $this->belongsTo(Category::class,'parent_id'); } }