Ejemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     if (!PaymentInfo::find($id)) {
         // return view('dashboard.supplierProfileEdit');
         return redirect()->back()->withErrors(['messages' => "Ödeme bilgisi bulunamadı"]);
     }
     $paymentInfo = PaymentInfo::find($id);
     if (Auth::user()->id != $paymentInfo->supplier_id) {
         //return view('dashboard.supplierProfileEdit');
         return redirect()->back()->withErrors(['messages' => "Ödeme bilgisi size ait değil"]);
     }
     $paymentInfoRules = array('title' => 'required', 'detail' => 'required');
     // do the validation ----------------------------------
     // validate against the inputs from our form
     $validator = Validator::make($request->all(), $paymentInfoRules);
     // check if the validator failed -----------------------
     if ($validator->fails()) {
         // get the error messages from the validator
         $updateProduct = $validator->messages();
         // redirect our user back to the form with the errors from the validator
         // return view('dashboard.supplierProfileEdit');
         return back()->withInput()->withErrors($validator);
     } else {
         $user = Auth::user();
         $paymentInfo->supplier_id = $user->id;
         $paymentInfo->title = $request->input('title');
         $paymentInfo->detail = $request->input('detail');
         $paymentInfo->update();
         return redirect()->back()->with('success', ['Ödeme bilgileriniz güncellendi']);
     }
 }