- add category management
This commit is contained in:
		| @@ -48,7 +48,7 @@ class CategoryRepository implements CategoryRepositoryInterface | ||||
|     public function update(Category $category, array $data = []): bool | ||||
|     { | ||||
|         $data = $this->parseToArray($data); | ||||
|         if (!$category->default && isset($data['default']) && $data['default'] === true) | ||||
|         if (!$category->default && $data['default'] === true) | ||||
|             $this->unsetDefault(); | ||||
|  | ||||
|         return $category | ||||
| @@ -58,7 +58,7 @@ class CategoryRepository implements CategoryRepositoryInterface | ||||
|     public function create(array $data = []): Category | ||||
|     { | ||||
|         $data = $this->parseToArray($data); | ||||
|         if (isset($data['default']) && $data['default'] === true) | ||||
|         if ($data['default'] === true) | ||||
|             $this->unsetDefault(); | ||||
|  | ||||
|         return $this->category | ||||
| @@ -85,18 +85,12 @@ class CategoryRepository implements CategoryRepositoryInterface | ||||
|         if (isset($data['priority']) && !is_integer($data['priority'])) | ||||
|             $toSave['priority'] = (int)$data['priority']; | ||||
|  | ||||
|         if ( | ||||
|             isset($data['default']) && | ||||
|             in_array($data['default'], ['yes', 'on', 1, true]) | ||||
|         ) $toSave['default'] = true; | ||||
|         else $toSave['default'] = false; | ||||
|         $toSave['default'] = $data['default']; | ||||
|  | ||||
|         if ( | ||||
|             (isset($toSave['default']) && $toSave['default'] === true) || | ||||
|             (isset($data['visible']) && | ||||
|             in_array($data['visible'], ['yes', 'on', 1, true])) | ||||
|         ) $toSave['visible'] = true; | ||||
|         else $toSave['visible'] = false; | ||||
|         if ($toSave['default'] === true) | ||||
|             $toSave['visible'] = true; | ||||
|         else | ||||
|             $toSave['visible'] = $data['visible']; | ||||
|  | ||||
|         return $toSave; | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user