msg = $data['msg'] ?? ''; $this->success = $data['success'] ?? true; if (empty($data['showType']) && $this->success) { $this->showType = ShowType::SUCCESS_MESSAGE; } elseif (empty($data['showType']) && ! $this->success) { $this->showType = ShowType::ERROR_MESSAGE; } else { $this->showType = ShowType::from($data['showType']); } $this->data = $data['data'] ?? []; parent::__construct($data['msg'] ?? '', $code); } public function toArray(): array { return [ 'data' => $this->data, 'success' => $this->success, 'msg' => $this->msg, 'showType' => $this->showType->value, ]; } }