2016-11-29 18 views
0

このコードを実行すると、新しい行がテーブルに挿入されます.i行内の既存の顧客を更新します。laravel 5.2で既存の顧客を更新する方法は?

public function savepayment(Request $request,$amount) 
{ 
    $title ='Save Payment'; 
    $payment = new Customer(); 
    $payment ->paid = 'yes'; 
    $payment->save(); 

    Session::flash('flash_notification', array('level' => 'success', 'message' => 'Amount Paid Successfully')); 

    return Redirect::action('Admin\[email protected]'); 
} 

答えて

0

あなたは、顧客の情報を更新するために顧客を見つける必要があり、この

public function savepayment(Request $request,$amount) 
{ 
    $title ='Save Payment'; 
    $payment = Customer::find('customer_id'); //need to find the customer before updating the existing customer 
    $payment ->paid = 'yes'; 
    $payment->update(); //use update() instead of save() 

    Session::flash('flash_notification', array('level' => 'success', 'message' => 'Amount Paid Successfully')); 

    return Redirect::action('Admin\[email protected]'); 
} 
+0

をお試しください – Jon

関連する問題