public function addCategory($attr) { $model = new Categories(); $model->setAttributes($attr); $model->status = 1; $model->created_at = time(); $model->updated_at = time(); if ($model->save(FALSE)) { return TRUE; } return FALSE; }
public static function create($data) { $response = new Response(); try { $data = json_decode($data, true); /** @var Products $products */ $category = new Categories(); $category->setAttributes($data); $response->data = $category->create(); $response->status = $response::STATUS_CREATED; } catch (Exception $e) { $response->setException($e); } finally { return $response->toArray(); } }