A column named ‘Shipment’ in import_request_trackers table having the datatype of Date and initially the default value is null.
$table->date('Shipment')->nullable(); $table->date('Arrival')->nullable();
But when I tried to update the column from another form manually it shows no error but the database table is not being updated.
public function shipmentadd(Request $request, $id){ $tracker = ImportRequestTracker::where('OrderNo', $id)->first(); $inputs = [ 'Shipment' => $request->input('ShipmentDate') ]; $tracker->update($inputs); return redirect()->route('developer.import.tracker');
}
Advertisement
Answer
1- check your route first, please note that your $id
is passing correctly!
2- check the data, you may use “dd($id , $request->input('ShipmentDate'))
to check it.
3- please note that your ShipmentDate data should have a certain structure like: 2022-12-01 or 2022/12/01 (Y-m-d or Y/m/d) and etc.
As a string in either ‘YYYY-MM-DD
‘ or ‘YY-MM-DD
‘ format. A “relaxed” syntax is permitted: Any punctuation character may be used as the delimiter between date parts. For example, '2012-12-31', '2012/12/31', '2012^12^31', and '2012@12@31'
are equivalent.
As a string with no delimiters in either ‘YYYYMMDD’ or ‘YYMMDD’ format, provided that the string makes sense as a date. For example, ‘20070523’ and ‘070523’ are interpreted as ‘2007-05-23’, but ‘071332’ is illegal (it has nonsensical month and day parts) and becomes ‘0000-00-00’.
As a number in either YYYYMMDD
or YYMMDD
format, provided that the number makes sense as a date. For example, 19830905
and 830905
are interpreted as '1983-09-05'
.
all in all, after cheking the data you may use this code:
public function shipmentadd(Request $request, $id){ $tracker = ImportRequestTracker::where('OrderNo', $id)->update([ 'Shipment' => $request->input('ShipmentDate'), ]); return redirect()->route('developer.import.tracker'); }