I have this Invoice model where I try to update member_id and district_id with null:
#attributes: array:14 [▼
"id" => 106
"number" => "20150505"
"date" => "2015-09-22 20:29:48"
"member_id" => null
"district_id" => null
"description" => " "
"items" => " "
"notes" => "uolo"
"po_number" => "123"
"amount" => "0"
"status" => "Paid"
"created_at" => "2015-09-22 19:20:32"
"updated_at" => "2015-09-22 20:26:41"
"receiver_details" => """
yono\r\n
asd\r\n
ads\r\n
\r\n
sad
"""
]
#original: array:14 [▼
"id" => 106
"number" => 20150505
"date" => "2015-09-22 20:26:41"
"member_id" => 166
"district_id" => 13
"description" => " "
"items" => " "
"notes" => "uolo"
"po_number" => "123"
"amount" => 0.0
"status" => "Paid"
"created_at" => "2015-09-22 19:20:32"
"updated_at" => "2015-09-22 20:26:41"
"receiver_details" => "yono"
]
The update is like this:
$invoice = $this->invoice->find($invoice_id);
$invoice->number = $number;
$invoice->date = Carbon::createFromFormat('m/d/Y', $date);
$invoice->member_id = $member_id;
$invoice->district_id = $district_id;
$invoice->description = $description;
$invoice->notes = $notes;
$invoice->items = $items;
$invoice->po_number = $po_number;
$invoice->amount = $amount;
$invoice->status = $status;
$invoice->receiver_details = $receiver_details;
dd($invoice);
$invoice->save();
What am I missing? The problem is that the member_id remains the original one and yes, the field in nullable.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire