コード例 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $input = $request->input();
     $update = DB::table('members')->where('id', $id)->update(['name' => $input['name'], 'address' => $input['address'], 'contactNumber' => $input['contactNumber'], 'email' => $input['email']]);
     $ret = DB::table('memberprofile')->where('uid', $id)->first();
     $company_document = array('company_document' => Input::file('company_document'));
     $destinationPath = 'upload';
     $companyDocumentExtension = Input::file('company_document')->getClientOriginalExtension();
     $companyDocumentName = rand(11111, 99999) . '.' . $companyDocumentExtension;
     Input::file('company_document')->move($destinationPath, $companyDocumentName);
     if ($ret) {
         $mpupdate = DB::table('memberprofile')->where('uid', $id)->update(['company_name' => $input['company_name'], 'company_address' => $input['company_address'], 'company_information' => $input['company_information'], 'company_document' => $companyDocumentName]);
     } else {
         $memprofile = new MemberProfile();
         $memprofile->uid = $id;
         $memprofile->company_name = $input['company_name'];
         $memprofile->company_address = $input['company_address'];
         $memprofile->company_information = $input['company_information'];
         $memprofile->company_document = $companyDocumentName;
         $memprofile->save();
     }
     Session::flash('message', 'Updated successfully');
     return Redirect::to('home');
 }
コード例 #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $input = $request->input();
     if (Input::file('company_document')) {
         $company_document = array('file' => Input::file('company_document'), 'extention' => Input::file('company_document')->getClientOriginalExtension());
         $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:pdf,doc,docx,jpeg,bmp,png');
         $validator = Validator::make($company_document, $rules);
         if ($validator->fails()) {
             Session::flash('message', 'File must be less than 2Mb and only pdf,doc,docx,jpeg,bmp,png');
             $agentp = DB::table('members')->whereId($id)->first();
             return view('agent.edit')->with('agentp', $agentp);
         } else {
             $destinationPath = 'upload';
             $companyDocumentExtension = Input::file('company_document')->getClientOriginalExtension();
             $companyDocumentName = rand(11111, 99999) . '_comp_docu' . '.' . $companyDocumentExtension;
             Input::file('company_document')->move($destinationPath, $companyDocumentName);
         }
     }
     $update = DB::table('members')->where('id', $id)->update(['name' => $input['name'], 'address' => $input['address'], 'contactNumber' => $input['contactNumber'], 'email' => $input['email']]);
     $ret = DB::table('memberprofile')->where('uid', $id)->first();
     if ($ret) {
         $mpupdate = DB::table('memberprofile')->where('uid', $id)->update(['company_name' => $input['company_name'], 'company_address' => $input['company_address'], 'company_information' => $input['company_information'], 'company_document' => isset($companyDocumentName) ? $companyDocumentName : '']);
     } else {
         $memprofile = new MemberProfile();
         $memprofile->uid = $id;
         $memprofile->company_name = $input['company_name'];
         $memprofile->company_address = $input['company_address'];
         $memprofile->company_information = $input['company_information'];
         $memprofile->company_document = isset($companyDocumentName) ? $companyDocumentName : '';
         $memprofile->save();
     }
     Session::flash('message', 'Updated successfully');
     return Redirect::to('home');
 }