/** * @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'), '获取成功'); }
/** * 增加约谈记录 */ public function interviewAdd() { // dd($this->request->all()); $interview = new Interview(); //获取约谈字段 $interview->investor_id = $this->user()->id; $interview->project_id = $this->request->get('project_id'); $interview->interview_date = $this->request->get('date'); $interview->interview_time = $this->request->get('time'); $interview->interview_address = $this->request->get('address'); // $interview->interview_amount = $this->request->get('amount'); $interview->interview_desc = $this->request->get('desc'); //查询项目创建人 $project = CompanyProject::find($interview->project_id); if (empty($project)) { return return_rest('0', '', '没有找到该项目'); } $customer = Customer::where('is_company_creator', 1)->where('company_id', $project->company_id)->first(); if (empty($customer)) { return return_rest('0', '', '该项目没有创始人'); } $interview->creator_id = $customer->id; if ($interview->save()) { return return_rest('1', '', '提交成功'); } return return_rest('0', '', '提交失败,约harry'); }