コード例 #1
0
 /**
  * 我的项目
  */
 public function mine()
 {
     $user = $this->user();
     //获取用户类型 是否为投资人
     if ($user->type == '2') {
         //该用户为投资人 获取用户投资列表
         $invest_project = InvestProject::select('project_id')->where('customer_id', $user->id)->get()->toArray();
         if (empty($invest_project)) {
             return return_rest('1', array('project' => array()), '暂无投资项目');
         }
         $project_id = array_pluck($invest_project, 'project_id');
         $project = CompanyProject::select('id', 'name', 'brief', 'logo')->whereIn('id', $project_id)->with('field')->get()->toArray();
         $i = 0;
         foreach ($project as $item) {
             //获取项目投资轮次
             $project_finance = DB::table('company_project_finance')->where('project_id', $item['id'])->orderBy('created_at', 'desc')->first();
             $project[$i]['project_finance'] = '天使轮';
             if ($project_finance) {
                 $project[$i]['project_finance'] = $this->financeName($project_finance->finance_id);
             }
             $i++;
         }
         return return_rest('1', compact('project'), '项目列表');
     }
     if ($user->company_id == 0) {
         $project['is_company'] = '0';
         $project['is_project'] = '0';
         return return_rest('1', compact('project'), '项目详情');
     }
     //获取项目信息
     $project = $this->project->select('id', 'name', 'logo', 'brief', 'finance_progress', 'company_id', 'target_amount', 'start_amount', 'get_out', 'subscribe', 'subscribe_amount', 'currency', 'city', 'view', 'share')->where('company_id', $user->company_id)->with('field')->first();
     if (is_null($project)) {
         return return_rest('1', array('is_company' => '1', 'is_project' => '0'), '该用户没有项目');
     }
     $project = $project->toArray();
     //项目介绍
     $project_introduce = DB::table('company_project_detail')->where('company_project_id', $project['id'])->first();
     if (!$project_introduce) {
         return return_rest('0', '', '项目介绍未添加,请联系harry');
     }
     $project['project_introduce'] = $project_introduce->project_introduce;
     //获取公司介绍
     $project['companyIntroduce'] = CompanyIntroduce::select('company_introduce.id', 'company_introduce.content', 'company_introduce_config.name')->where('company_id', $project['company_id'])->leftJoin('company_introduce_config', 'company_introduce.config_id', '=', 'company_introduce_config.id')->orderBy('company_introduce.config_id', 'asc')->get()->toArray();
     //获取企业网站
     $project['website'] = Company::where('id', $user->company_id)->first()->website;
     //获取项目优势
     $project['teamAdvantage'] = "";
     $company_extend = CompanyExtend::select('story')->where('company_id', $user->company_id)->first();
     if ($company_extend) {
         $project['teamAdvantage'] = $company_extend->story;
     }
     $project['is_company'] = '1';
     $project['is_project'] = '1';
     //获取项目投资轮次
     $project_finance = DB::table('company_project_finance')->where('project_id', $project['id'])->orderBy('created_at', 'desc')->first();
     $project['project_finance'] = '天使轮';
     if ($project_finance) {
         $project['project_finance'] = $this->financeName($project_finance->finance_id);
     }
     return return_rest('1', compact('project'), '项目详情');
 }
コード例 #2
0
ファイル: CompanyController.php プロジェクト: jodacz007/base
 public function edit($id)
 {
     $this->checkPageAction($this->page_id, Action::$Edit);
     if (!Company::find($id)) {
         $this->diplayError(404);
     }
     if (Request::ajax() && Input::has('actionType')) {
         $responce = array();
         switch (Input::get('actionType')) {
             case 'checkCompany':
                 if (Input::has('company_name')) {
                     $name = Input::get('company_name');
                     $data = Company::where(array('company_name' => $name))->where('company_id', '<>', $id)->get();
                     if (count($data) > 0) {
                         return 'false';
                     }
                 }
                 return 'true';
                 break;
             case 'updateCompany':
                 if (Request::isMethod('post') && Input::has('company') && Input::has('companyInfo')) {
                     if (!Company::find($id)) {
                         return json_encode(array('msg' => 'Unable to find company info, Please try again later!'));
                     } else {
                         $company_detail = json_decode(Input::get('company'), TRUE);
                         $company_info = json_decode(Input::get('companyInfo'), TRUE);
                         $company = Company::find($id);
                         $prevData = $company->toArray();
                         $company->fill($company_detail);
                         if ($company->save()) {
                             $company->companyInfo->fill($company_info);
                             if ($company->companyInfo->save()) {
                                 return json_encode(array('status' => 'true', 'msg' => 'Successfully Updated Company!'));
                             } else {
                                 $company->fill($prevData);
                                 $company->save();
                                 return json_encode(array('status' => 'false', 'msg' => 'Unable To Update Company!'));
                             }
                         }
                         return json_encode(array('status' => 'false', 'msg' => 'Unable To Update Company!'));
                     }
                 }
                 break;
         }
     }
     return view('content.setting.company.form.company_form', array('company_info' => Company::find($id)));
 }