コード例 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //
     if (Request::hasFile('image')) {
         $v = Validator::make(Request::all(), ['image' => 'mimes:jpeg,jpg,png']);
         if ($v->fails()) {
             return redirect()->back()->withErrors($v->errors())->withInput();
         } else {
             $userId = Request::get('id');
             //Request::get('id')=$id;
             // $userId=Request::get('id');
             //echo $userId;
             $gInfo = Generalinfo::where('user_id', $userId)->get();
             $gInfoId = $gInfo[0]->id;
             //echo $gInfoId;
             $gInfo = Generalinfo::find($gInfoId);
             $destination = 'uploads/';
             $imagename = str_random(6) . "_" . Request::file('image')->getClientOriginalName();
             Request::file('image')->move($destination, $imagename);
             // $path = Request::file('image')->getRealPath();
             // echo $path;
             //$path = public_path('upload/' . $imagename);
             //Image::make(Request::file('image')->getRealPath())->resize(200, 200)->save($path);
             $gInfo->image = $imagename;
             $gInfo->save();
             return redirect('generalinfos/' . $userId);
         }
     }
     //////////////update rest of data/////////////////////////
     $v = Validator::make(Request::all(), ['city' => 'required|max:30', 'dob' => 'required', 'phone' => 'required']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     } else {
         $userId = Request::get('id');
         $gInfo = Generalinfo::where('user_id', $userId)->get();
         $gInfoId = $gInfo[0]->id;
         $gInfo = Generalinfo::find($gInfoId);
         $gInfo->country_id = Request::get('country');
         $gInfo->city = Request::get('city');
         $gInfo->dob = Request::get('dob');
         $gInfo->address = Request::get('address');
         $gInfo->phone = Request::get('phone');
         $gInfo->anotherphone = Request::get('anotherphone');
         $gInfo->skypename = Request::get('skypename');
         $gInfo->howhearaboutus = Request::get('howhearaboutus');
         $gInfo->save();
         DB::table('user_interests')->where('user_id', $userId)->delete();
         $userInterest = new UserInterest();
         $userInterest->user_id = $userId;
         $userInterest = Request::get('interest');
         foreach ($userInterest as $userInterest_id) {
             // echo $userInterest_id;
             DB::insert('INSERT INTO user_interests (interest_id, user_id) VALUES (?,?)', array($userInterest_id, $userId));
         }
         return redirect('generalinfos/' . $userId);
     }
 }
コード例 #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //
     $v = Validator::make(Request::all(), ['city' => 'required|max:30', 'dob' => 'required', 'phone' => 'required']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     } else {
         $userId = Request::get('id');
         $gInfo = Generalinfo::where('user_id', $userId)->get();
         $gInfoId = $gInfo[0]->id;
         $gInfo = Generalinfo::find($gInfoId);
         $gInfo->country_id = Request::get('country');
         $gInfo->city = Request::get('city');
         $gInfo->dob = Request::get('dob');
         $gInfo->image = Request::get('image');
         $gInfo->address = Request::get('address');
         $gInfo->phone = Request::get('phone');
         $gInfo->anotherphone = Request::get('anotherphone');
         $gInfo->skypename = Request::get('skypename');
         $gInfo->howhearaboutus = Request::get('howhearaboutus');
         $gInfo->save();
         $interestId = Request::get('interest');
         // UserInterest::where('user_id',$userId)->update['interest_id'=>$interestId];
         UserInterest::where('user_id', $userId)->update(['interest_id' => $interestId]);
         return redirect('generalinfos/' . $userId);
     }
 }