1
0
Fork 0

app/Models/Recipe.php: Change getNameAttribute() and getSlugAttribute() to prioritize spell relationship before craft.

This commit is contained in:
Henrik Hautakoski 2021-07-08 13:23:20 +02:00
parent 21ff933939
commit 8c3a5ddef1

View file

@ -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;
}
}