last day (15 days later) » 

8:09 PM
1
Q: storing data in db using AngularJS & laravel 5

user3641381I 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"...

 
@FabioAntunes I pass the $request in the constructor. This is not the issue. When the plate object comes in I need to reach the id of it, which is 3. So how can go about that? I have tried $data = $request->all() and than $data['plate_id'] but is not working :(
@FabioAntunes Not sure how to debug this. I am filling the from in my front-end how can I make sure the back-end receives it? I am not sure if var_dump will cut it.
@FabioAntunes I gave it a try. Everything seems working. I get 200 status code on my API ( network pane). The var_dump is not showing anything on the console.log. Is there anyway to show if the object is actually reaching the method in the back-end?
 
Try to make request in chrome, and then inspect network panel with this request. And instead of var_dump better use laravel dd() function. And in your service no need in $.params, you can set just data object to send. And headers field is not required. Try method="POST".
 
@EchoUA.COM I have tried, either dd or var_dump are not appearing in the console. In the network panel I get status 500 ( which there is something wrong with my back-end). I am confused now. How can I make request from chrome ( or what do you mean)?
 
Info show in network panel, not console. take.ms/Kd7Pv
 
@EchoUA.COM as I said I get status code 500. Check the update above
@EchoUA.COM I can't seem to find response panel in my chrome dev tools. Any ideas?
 
8:09 PM
500 code means it's server error. Try to pass Request $request to your function. You store request to contructor, but use it as regular variable.
 
I do have Request $request in my function
I had it in my constructor, but for testing purposes move it to the function
 
and still have 500 error and nothing in response tab?
 
Yes
Do you any idea how to toggle response tab
can't seem to find
in my network panel
 
1 second
some test message
i recorded little video. check if you do same thing
 
just a minute
okay I check it
I get Call to a member function equipmentStatusCode() on null
which means it's not getting the id from the object
I wil try dd for a second
$data = (object)$request->all();
dd($data);
working just fine
 
8:25 PM
can you store your current controller code?
 
no
because it can't reach the id
this is my code
$data = (object)$request->all();

// $input = (object)Input::all();
// $jsonArray = $input->data;


// Document update
$plate = Plate::find($request->get('plate_id'));
$doc = Document::find($request->input('document_id'));
$plate->documents()->attach($doc->id);
error
FatalErrorException in PlatesInspectionController.php line 76:
Call to a member function documents() on null
I have tested the code above 100 times. And it works.
 
$request->get('plate_id') must be $request->input('plate_id'), or $request->plate_id or $data->plate_id
and it better to add checker after $plate = ///
if (!$plate) { return 'error'; }
 
$request->input('plate_id) is not working either..
I will check $data->plate_id
 
And try dd($data) to check if there 'plate_id' exists
 
I will show you how the data comes in.. just a minute
maybe I am doing something wrong.
this is the dd
array:1 [
"{"procedure":{"id":2,"name":"Bart_Steuber","description":"Et_","relative_path":"Ab_","process_id":22,"geometry_id":27,"metrologydatatype_id":2,"coating_id":9,"robot_id":17,"data_representationtype_id":3,"platetype_id":29,"dies_id":1,"wafer_id":17,"assemblyjig_id":5,"bracket_id":20,"xray_measurement_id":22,"vacuum_pattern_id":11,"mandrel_id":8,"stack_id":28,"mirror_module_id":4,"created_at":"2015-11-29_19:18:24","updated_at":"2015-11-29_19:18:24"},"plate":{"id":2,"serial_number":5607468,"crc-code":"8","reason":null,"stack_id":9,"plate_container_id":5,"container_slot_id":22,"equipm
the dd shows a plate object and a document
I need the id's in this case to execute the controller
the id's are both 2 in this case
should I do something like $request->input('procedure.id') ?
 
8:40 PM
it's dd($data)?
Why you use (object) transform?
 
yes it's the dd($data)
I was just testing it..
I tried it without it though.. doesn't work
 
try to dd($request->all()); and show result there
 
array:1 [
"{"document":{"id":2,"name":"Bart_Steuber","description":"Et_","relative_path":"Ab_","process_id":22,"geometry_id":27,"metrologydatatype_id":2,"coating_id":9,"robot_id":17,"data_representationtype_id":3,"platetype_id":29,"dies_id":1,"wafer_id":17,"assemblyjig_id":5,"bracket_id":20,"xray_measurement_id":22,"vacuum_pattern_id":11,"mandrel_id":8,"stack_id":28,"mirror_module_id":4,"created_at":"2015-11-29_19:18:24","updated_at":"2015-11-29_19:18:24"},"plate":{"id":3,"serial_number":881782,"crc-code":"2","reason":null,"stack_id":5,"plate_container_id":1,"container_slot_id":18,"equipmen
do you know how can I reach the id of the document
because $request->document_id is not working
I get null returned
 
8:57 PM
problem in your js code. data sended in wrong format
try update your service
inspectionUpdate: function(inspectionData) {
return $http({
url: '/api/v1/plateinspection/',
method: 'PUT',
data: inspectionData
});
}
 
How would I make it in right format?
This is what I have after you told me to do so..
 
inspectionUpdate: function(inspectionData) {
console.log(inspectionData);
return $http({
url: '/api/v1/plateinspection/',
method: 'PUT',
data: inspectionData
});
}
and show what in your console is shown
 
array:2 [
"document" => array:22 [
"id" => 2
"name" => "Bart Steuber"
"description" => "Et."
"relative_path" => "Ab."
"process_id" => 22
"geometry_id" => 27
"metrologydatatype_id" => 2
"coating_id" => 9
"robot_id" => 17
"data_representationtype_id" => 3
"platetype_id" => 29
"dies_id" => 1
"wafer_id" => 17
"assemblyjig_id" => 5
"bracket_id" => 20
"xray_measurement_id" => 22
"vacuum_pattern_id" => 11
"mandrel_id" => 8
"stack_id" => 28
"mirror_module_id" => 4
"created_at" => "2015-11-29 19:18:24"
"updated_at" => "2015-11-29 19:18:24"
this is dd($request->all())
 
It's not console.
And it's not full data, it's only half of array
 
I am doing dd($request->all()) so I don't get anything in my console
 
9:08 PM
I updated your service code
inspectionUpdate: function(inspectionData) {
console.log(inspectionData);
return $http({
url: '/api/v1/plateinspection/',
method: 'PUT',
data: inspectionData
});
}

Your site is local or somewhere on internet?
If you want, I can try to check everything over teamviewer
 
okay let's do it via teamviewer
 
give me your teamviewer id and password
 
283 467 244
5570
 

last day (15 days later) »