From 8c3a5ddef1bc54199ca019a8499d1d70bc4e098c Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Thu, 8 Jul 2021 13:23:20 +0200 Subject: [PATCH] app/Models/Recipe.php: Change getNameAttribute() and getSlugAttribute() to prioritize spell relationship before craft. --- app/Models/Recipe.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Models/Recipe.php b/app/Models/Recipe.php index 4141d50..d45229c 100644 --- a/app/Models/Recipe.php +++ b/app/Models/Recipe.php @@ -123,18 +123,24 @@ class Recipe extends Model } /** - * Get recipe name from crafted item. + * Get recipe name from crafted item or spell. */ public function getNameAttribute() { + if ($this->spell) { + return $this->spell->name; + } return $this->craft->name; } /** - * Get recipe slug from crafted item. + * Get recipe slug from crafted item or spell. */ public function getSlugAttribute() { + if ($this->spell) { + return $this->spell->slug; + } return $this->craft->slug; } }