0

i am using this code in laravel .

 $user_detail = \App\Userpacakage::with('user.pacakage')->where('pacakage_id', '=', 1)->get(); //->lists('nombre', 'id')
        return response()->json($user_detail);

this is my json output ->

[{"id":1,"user_id":1,"pacakage_id":1,"transaction_id":"jfjkgjgjkhkjkg55rtf","created_at":"-0001-11-30 00:00:00","updated_at":"-0001-11-30 00:00:00","user":{"id":1,"name":"omsun","email":"[email protected]","contact":2147483647,"regkey":"","created_at":"2015-11-21 01:18:33","updated_at":"2015-11-21 01:18:33","pacakage":[{"id":1,"title":"dsagdjas","description":"<p>\r\n\tsamndbmasndmas,<\/p>\r\n","tab_id":0,"from":"11\/27\/2015","to":"12\/03\/2015","days":22,"unlimited":0,"criteria":1,"category_id":1,"subcategory_id":0,"subject_id":0,"price":2432,"created_at":"2015-11-21 19:07:10","updated_at":"2015-11-21 19:07:10","pivot":{"user_id":1,"pacakage_id":1}}]}}]

using jquery i am using this code to fetch user details

$.get('api/classallocation?pacakage_id=' + pacakage_id, function (data) {

                    console.log(data);
                     $.each(data, function (i, user) {

                         console.log(user.name));
                     });

i want to know how to fetch the pacakage details in jquery ..like pacakage title ,price.

4
  • what exactly is your question? please add more information on what input you give and the output you get, and what your code looks like. Commented Nov 22, 2015 at 0:18
  • i am laravel $user_detail = \App\Userpacakage::with('user.pacakage')->where('pacakage_id', '=', 1)->get(); //->lists('nombre', 'id'); return response()->json($user_detail); Commented Nov 22, 2015 at 0:36
  • And what is the error or problem you have with the parsing? Please update your question. Commented Nov 22, 2015 at 8:42
  • now i have updated the question .pls help Commented Nov 22, 2015 at 10:11

1 Answer 1

1
$.get('api/classallocation?pacakage_id=' + pacakage_id, function (data) {
   console.log(data);
   $.each(data, function (i, user) {
   console.log(user.pacakage[0].title));
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.