I have a setup like this.
My html
<div class="panel-body">
<div class="form-group form-group-lg">
<label class="col-sm-2 control-label">Select a plate</label>
<div class="col-sm-10">
<select class="form-control m-t" id="plate_id" ng-model="inspectionData.plate" ng-options="plate as (plate.serial_number) for plate in plates" required>
<option value="">Please choose
<span class="symbol required"></option>
</select>
</div>
</div>
</div>
and my controller looks like this.
$scope.storePlatesInspection = function() {
PlatesInspectionFactory.inspectionUpdate($scope.inspectionData)
.success(function(data)
{
$scope.ServerResponse = data;
sweetAlert('Nailed it!', 'Your entered data was send to database', 'success');
console.log($scope.inspectionData);
})
.error(function(data) {
sweetAlert("Oops...", "Something went wrong!", "error");
console.log($scope.inspectionData);
});
};
my service
inspectionUpdate: function(inspectionData) {
return $http({
url: '/api/v1/plateinspection/',
method: 'PUT',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data: $.param(inspectionData)
});
}
All I want to take the selected data and send it back though the API and save it.
I am confused on how to catch all the objects being send from Angular
here is what I have been trying.
public function storePlateInspectionData(){
$plate = Plate::find($request->input('plate_id'));
$doc = Document::find($request->input('document_id'));
$plate->documents()->attach($doc->id);
}
Should I use Input::all()
or request->all()
what are the best practices of doing this.
The $request->input('plate_id)
is not working. Someone please help out.
This is what I get In my console
In this case I want the id
which is 3
to save the data. How Can I achieve this?
update status code 500