Example #1
0
 /**
  * 修改个人资料
  * GET /users/update
  */
 public function update()
 {
     validate(['avatar' => 'max:255', 'nickname' => 'max:32', 'gender' => 'in:unknown,male,female', 'year_of_birth' => 'integer', 'month_of_birth' => 'integer', 'day_of_birth' => 'integer']);
     $params = inputAll();
     if (!$params || count($params) <= 0) {
         respondUnprocessable('没有资料更改');
     }
     $user = user();
     $updated = $this->usersInterface->update($user, $params);
     if (!$updated) {
         respondUnprocessable('没有资料更改');
     }
     return respondWithItem($user);
 }
Example #2
0
 /**
  * 删除帖子
  * POST /posts/{post_id}/destroy
  */
 public function destroy($postId)
 {
     $records = $this->postInterface->delete($postId);
     if ($records) {
         return respondSuccess('删除帖子成功');
     }
     respondUnprocessable('删除失败');
 }