Questions tagged [laravel-eloquent-resource]
35 questions
0
votes
1 answer
Including relationships in eloquent resource collection optionally
I want load relationship optionally on collection api end point
The end point will be something like
http://127.0.0.1:8000/api/posts/?include=comments includes comments with posts and I can add more using comma,…

Prafulla Kumar Sahu
- 9,321
- 11
- 68
- 105
0
votes
0 answers
Insert foreign keys using eloquent laravel
I have 2 tables - questions and responses. I want to insert question_ids for every answer given into responses' table(a survey system). I have been able to insert answers, but not corresponding question_ids into responses' table.Here is my…
0
votes
3 answers
Getting data in response, but after rendering the view through ajax not getting few data
Laravel: 5.7.25
PHP 7.2.10
Sample data in response
{,…}
data: [{id: 1,…}, {id: 2,…}, {id: 3,…}, {id: 4,…}, {id: 5,…}, {id: 6,…}, {id: 7,…}, {id: 8,…}, {id: 9,…},…]
0: {id: 1,…}
carModelBodyType: {id: 1, name: "Sedan", status: 1, created_at:…

Prafulla Kumar Sahu
- 9,321
- 11
- 68
- 105
-1
votes
2 answers
WHERE EQUALS TO SUBQUERY SELECT
i just want to know how can I convert this query into laravel eloquent query .
"SELECT * FROM vw_part_supplier
LEFT JOIN purchase_request_detail ON vw_part_supplier.part_supp_id = purchase_request_detail.prd_part_supp_id
…

Kabergrammer
- 9
- 1
- 4
-3
votes
1 answer
How to alter data in relations field in laravel eloquent model after returning result?
I'm working with Laravel 5.6. And fetching data from database using Eloquent model. On that returned result set I found "relations" field as empty. But I need to alter this "relations" filed with some custom data. How should I do that?
My returned…

leaveme_alone
- 576
- 2
- 5
- 24