Example #1
0
 /**
  * @api {get} /customer 当前用户信息
  * @apiDescription 当前用户信息
  * @apiGroup user
  * @apiPermission JWT
  * @apiVersion 0.1.0
  * @apiSuccessExample {json} Success-Response:
  *     HTTP/1.1 200 OK
  *     {
  *       "data": {
  *         "id": 2,
  *         "email": '*****@*****.**',
  *         "name": "foobar",
  *         "created_at": "2015-09-08 09:13:57",
  *         "updated_at": "2015-09-08 09:13:57",
  *         "deleted_at": null
  *       }
  *     }
  */
 public function show()
 {
     $user = $this->modelCustomer->select('id', 'name', 'user_name', 'mobile', 'avatar', 'nickname', 'brief', 'type', 'type_state', 'sex', 'email', 'address', 'company_id', 'position', 'wechat')->withOnly('company', array('id', 'name', 'website', 'finance_status', 'weixin'))->find($this->user()->id);
     $user = $user->toArray();
     //如果用户为投资人 获取投资人相关字段
     if ($user['type'] == '2') {
         //获取投资人信息
         $user['investor'] = DB::table('customer_investor')->where('customer_id', $user['id'])->first();
         $user['invest'] = DB::table('customer_invest_field')->where('customer_id', $user['id'])->get();
         if (is_null($user['investor'])) {
             $user['investor'] = array();
         }
         if (count($user['invest']) == 0) {
             $user['invest'] = array();
         }
         //获取投资人公司
         $user['company'] = DB::table('invest_company')->select('id', 'name', 'brief', 'website', 'weixin')->where('id', $user['company_id'])->first();
         if (!is_null($user['company'])) {
             $user['company']->finance_status = "";
         }
     }
     $user['is_company'] = is_null($user['company']) ? '0' : '1';
     //判断用户是否有项目
     $user['is_project'] = '0';
     if ($user['is_company'] == '1' && $user['type'] == '1') {
         $project = CompanyProject::where('company_id', $user['company_id'])->first();
         if (!is_null($project)) {
             $user['is_project'] = '1';
         }
     }
     $user['company'] = is_null($user['company']) ? "" : $user['company'];
     return return_rest('1', compact('user'), '获取成功');
 }