I have gotten a form of the array to work it seems, though something is still showing up as off when I go to submit the data. Here is my store function:
public function store(Shipment $request)
{
$this->validate(request(), [
'pro_number' => 'required',
'shipment_origin' => 'required'
]);
$user_id = Auth::id();
$input = $request->all();
//Save Initial Shipment Data
$shipment = new Shipment();
$shipment->pro_number = request('pro_number');
$shipment->shipment_origin = request('shipment_origin');
$shipment->date = request('date');
$shipment->due_date = request('due_date');
$shipment->tractor_id = request('tractor_id');
$shipment->trailer_id = request('trailer_id');
$shipment->driver_id = request('driver_id');
$shipment->notes = request('notes');
$shipment->shipper_no = request('shipper_no');
$shipment->ship_to = request('ship_to');
$shipment->ship_from = request('ship_from');
$shipment->bill_to = request('bill_to');
$shipment->bill_type = request('bill_type');
$shipment->load_date = request('load_date');
$shipment->shipment_status = 0;
$shipment->created_by = $user_id;
$shipment->save();
//Save Shipment Details
$data = array();
foreach ($request->get('shipment_details') as $shipmentDetails){
$piecesNumber = $shipmentDetails['piecesNumber'];
$piecesType = $shipmentDetails['piecesType'];
$rateType = $shipmentDetails['rateType'];
$charge = $shipmentDetails['charge'];
$weight = $shipmentDetails['weight'];
$hazmat = $shipmentDetails['hazmat'];
$description = $shipmentDetails['description'];
$shipment->shipment_details()->save($shipment_detail);
}
//Return to Register
return redirect('/shipments');
}
But whenever I go to save it, I get the following response:
Type error: Argument 1 passed to Illuminate\Database\Grammar::columnize() must be of the type array, string given, called in ...\truckin\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php on line 131
I believe the error originates somewhere in my saving of shipment_details, though I'm not entirely certain where. It's likely I'm just overlooking something simple, this is new territory to me and I haven't quite gotten a grasp of this stuff yet. If you have any thoughts on this, I'd appreciate the help.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire