isMethod('get')) { return []; } return [ 'name' => 'required|array', 'name.*' => 'required|string', 'image' => 'nullable', 'parent_id' => 'nullable', 'popular' => 'nullable', 'brands' => 'nullable|array', 'position' => 'nullable|numeric' ]; } public function getName(): array { return $this->get('name'); } public function getSlug(): string { return Str::slug($this->get('name')['uz']); } public function getImage(Category $category): ?string { if ($this->hasFile('image')) { Storage::delete($category->image); return Uploads::store($this->file('image'), 'uploads/categories'); } return $category->image; } public function getFilterPower() { if ($this->get('is_filter_power') == 'true') { return true; } return false; } public function getPublished() { if ($this->get('published') == 'true') { return true; } return false; } public function getCredit() { if ($this->get('credit') == 'true') { return true; } return false; } public function getParentId() { if ($this->get('parent_id') > 0) return $this->get('parent_id'); return null; } public function getPosition(): int { return $this->get('position'); } public function getPopular(): bool { if ($this->get('popular') == 'false') { return false; } return true; } }