slug($value)->firstOrFail(); } /** * Get all characters with this profession. */ public function characters() { return $this->belongsToMany(Character::class); } /** * What recipes this profession has */ public function recipes() { return $this->hasMany(Recipe::class); } public function scopeSlug($q, $name) { return $q->where('name', Str::ucfirst($name)); } public function getSlugAttribute() { return Str::lower($this->name); } }