storage url o'zgartirildi
This commit is contained in:
@@ -8,6 +8,13 @@ use Illuminate\Support\Str;
|
||||
|
||||
class Request extends FormRequest
|
||||
{
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
if (in_array($this->get('parent_id'), [0, '0', '', 'null', 'NULL'], true)) {
|
||||
$this->merge(['parent_id' => null]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@@ -22,7 +29,7 @@ class Request extends FormRequest
|
||||
'name' => 'required|array',
|
||||
'name.*' => 'required|string',
|
||||
'image' => 'nullable|mimes:jpg,jpeg,png',
|
||||
'parent_id' => 'nullable',
|
||||
'parent_id' => 'nullable|integer|exists:categories,id',
|
||||
'brands' => 'nullable|array',
|
||||
'position' => 'nullable|numeric'
|
||||
];
|
||||
@@ -82,15 +89,16 @@ class Request extends FormRequest
|
||||
|
||||
public function getParentId()
|
||||
{
|
||||
if ($this->get('parent_id') > 0)
|
||||
return $this->get('parent_id');
|
||||
if ((int) $this->get('parent_id') > 0) {
|
||||
return (int) $this->get('parent_id');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getPosition(): int
|
||||
{
|
||||
return $this->get('position');
|
||||
return (int) $this->get('position');
|
||||
}
|
||||
|
||||
public function getPopular(): bool
|
||||
|
||||
@@ -10,6 +10,13 @@ use Illuminate\Support\Str;
|
||||
|
||||
class Update extends FormRequest
|
||||
{
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
if (in_array($this->get('parent_id'), [0, '0', '', 'null', 'NULL'], true)) {
|
||||
$this->merge(['parent_id' => null]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@@ -24,7 +31,7 @@ class Update extends FormRequest
|
||||
'name' => 'required|array',
|
||||
'name.*' => 'required|string',
|
||||
'image' => 'nullable',
|
||||
'parent_id' => 'nullable',
|
||||
'parent_id' => 'nullable|integer|exists:categories,id',
|
||||
'popular' => 'nullable',
|
||||
'brands' => 'nullable|array',
|
||||
'position' => 'nullable|numeric'
|
||||
@@ -80,15 +87,16 @@ class Update extends FormRequest
|
||||
|
||||
public function getParentId()
|
||||
{
|
||||
if ($this->get('parent_id') > 0)
|
||||
return $this->get('parent_id');
|
||||
if ((int) $this->get('parent_id') > 0) {
|
||||
return (int) $this->get('parent_id');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getPosition(): int
|
||||
{
|
||||
return $this->get('position');
|
||||
return (int) $this->get('position');
|
||||
}
|
||||
|
||||
public function getPopular(): bool
|
||||
|
||||
@@ -43,7 +43,7 @@ class Store
|
||||
|
||||
$category->save();
|
||||
|
||||
$category->brands()->sync($request->brands, false);
|
||||
$category->brands()->sync($request->brands ?? [], false);
|
||||
|
||||
return $category;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user