1
0
Fork 0

app/Jobs/ImportProfession.php: should not use firstOrFail() when searching for items. as this will do an abort(404), that is very confusing.

This commit is contained in:
Henrik Hautakoski 2021-06-29 18:26:37 +02:00
parent 329c753105
commit 8e887d1ebe

View file

@ -79,7 +79,10 @@ class ImportProfession implements ShouldQueue
// Create recipes for character
foreach($this->recipes as $data) {
$item = Item::where('name', $data->name)->firstOrFail();
$item = Item::where('name', $data->name)->first();
if (!$item) {
throw new Exception("Could not find item '{$data->name}'");
}
$recipes[] = $this->getRecipe($item, $profession, $data)->id;
}
@ -129,7 +132,10 @@ class ImportProfession implements ShouldQueue
// Reagents
foreach($data->items as $reagent) {
$item = Item::where('name', $reagent->name)->firstOrFail();
$item = Item::where('name', $reagent->name)->first();
if (!$item) {
throw new Exception("Could not find item '{$reagent->name}'");
}
$recipe->reagents()->attach($item, [ 'quantity' => $reagent->num ]);
}