当我运行此代码时,会在表中插入一个新行。我想要连续更新现有客户。
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\CustomerController@paymentcustomer');
}
答案 0 :(得分: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\CustomerController@paymentcustomer');
}