More tweaks to the form request

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-07-05 05:59:39 +01:00
parent b3cc7b1578
commit 0d6fd2643d

View file

@ -21,11 +21,11 @@ class StoreAssetModelRequest extends ImageUploadRequest
{
if ($this->category_id) {
$this->category_type = Category::find($this->category_id)->category_type;
$this->merge([
'category_type' => $this->category_type,
]);
if ($category = Category::find($this->category_id)) {
$this->merge([
'category_type' => $category->category_type ?? null,
]);
}
}
}
@ -48,4 +48,9 @@ class StoreAssetModelRequest extends ImageUploadRequest
$messages = ['category_type.in' => trans('admin/models/message.invalid_category_type')];
return $messages;
}
public function response(array $errors)
{
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);
}
}