slug = Str::slug($item->name); }); } /** * Get the route key for the model. * * @return string */ public function getRouteKeyName() { return 'slug'; } public function recipes() { return $this->hasMany(Recipe::class); } public function getQuantityAttribute() { if ($this->pivot) { return $this->pivot->quantity; } return null; } }