Show some code and the the complete error
Please help me in solving this MYSQL Issue.
This is my Laravel application and the database is MySql.
I have many tables, out of which four tables are called 'customers', 'items', 'linked', & 'orders' respectively. However, the linked table is to link the items to different customers with different details. Now the issue that I'm facing is, lets assume in my linked table customer A has got 455 items and I'm getting this error "SQLSTATE[23000]: Integrity constraint violation: 1048 Column", and what amazes me is if I remove just 2 items and keep the items count just 453 then it works absolutely fine. Any help would be appreciated.
below is the store function from controller.
public function store(Request $request){
// code for single product without ARRAY
$linkeds = Linked::all();
$count_linkeds = request()->session()->get('count_linkeds');
$val = $count_linkeds;
$order_unq_id = $request->all('order_unq_id');
request()->session()->put('order_unq_id', $order_unq_id);
session()->save();
for ($i = 0; $i < $val; $i++)
{
$item_quantity = $request->item_quantity;
$itemTotal = $request->itemTotal_input[$i];
$item_unit_measure_input[] = $request->item_unit_measure_input[$i];
if($item_quantity > 0 && $itemTotal != null) {
$myitem = array(
'order_unq_id' => $request->order_unq_id,
'customerName_input' => $request->customerName_input,
'linked_id' => $request->linked_id,
'product_name_input' => $request->product_name_input[$i],
'item_name_input' => $request->item_name_input[$i],
'item_no_input' => $request->item_no_input[$i],
'item_description_input' => $request->item_description_input[$i],
'supplier_ref_no_input' => $request->supplier_ref_no_input[$i],
'supplier_barcode_input' => $request->supplier_barcode_input[$i],
'item_cost_input' => $request->item_cost_input[$i],
'item_quantity' => $request->item_quantity[$i],
'itemUnitMeasureInput' => $request->item_unit_measure_input[$i],
'itemTotal_input' => $request->itemTotal_input[$i],
'subtotal_input' => $request->subtotal_input,
'tax_input' => $request->tax_input,
'total' => $request->total_input,
"created_at" => now(),
"updated_at" => now()
);
DB::table('orders')->insert($myitem);
}else{
unset($myitem);
}
}
request()->session()->put('item_unit_measure_input', $item_unit_measure_input);
session()->save();
// dd($item_unit_measure_input);
return $this->mht_order_pdf();
return $this->export();
return redirect()->route('orders.index')->with('message', 'Order Created Successfull');
}
below is the error.
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'order_unq_id' cannot be null (SQL: insert into orders (order_unq_id, customerName_input, linked_id, product_name_input, item_name_input, item_no_input, item_description_input, supplier_ref_no_input, supplier_barcode_input, item_cost_input, item_quantity, itemUnitMeasureInput, itemTotal_input, subtotal_input, tax_input, total, created_at, updated_at)
Please or to participate in this conversation.