app/Models/Recipe.php: in resolveRouteBinding() find record by spell slug first, then crafted item.
This commit is contained in:
parent
8c3a5ddef1
commit
ff4f6b0612
1 changed files with 11 additions and 2 deletions
|
|
@ -55,9 +55,18 @@ class Recipe extends Model
|
|||
*/
|
||||
public function resolveRouteBinding($value, $field = null)
|
||||
{
|
||||
return $this->whereHas('craft', function ($q) use ($value) {
|
||||
$spell = $this->whereHas('spell', function ($q) use ($value) {
|
||||
$q->where('slug', $value);
|
||||
})->firstOrFail();
|
||||
})->first();
|
||||
|
||||
// Fallback on crafted item.
|
||||
if (!$spell) {
|
||||
return $this->whereHas('craft', function ($q) use ($value) {
|
||||
$q->where('slug', $value);
|
||||
})->first();
|
||||
}
|
||||
|
||||
return $spell;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Reference in a new issue