function execute() { $user = (int) Request::post('user'); $status = Request::post('status'); $model = new connectionUserModel(); $userInfo = $model->getInfo($user); $statusList = $model->getStatuses(); if (!$userInfo) { return array('status' => 'error', 'message' => '[`Title error invalid user`]'); } if (!isset($statusList[$status])) { return array('status' => 'error', 'message' => '[`Title error invalid status`]'); } if ($status != $userInfo['status']) { $model->changeStatus($user, $status); } return array('status' => 'success', 'title' => $statusList[$status]['title'], 'color' => $statusList[$status]['color']); }