I am a beginner to the Laravel framework. In this case, I have used Eager Loading. Also, I have assigned data to a Variable called $articles. After that, I have used WHERE IN Condition to fetch related data. Finally I have returned $articles variable. Below, there is my code. But Unfortunately, my code is not working properly. Are there any solutions for this? Thank You
Asked
Active
Viewed 531 times
-2

Kanchana Kariyawasam
- 43
- 9
-
Dont't post images of code, post the code in a code block in your question, also, define what the error/problem is. – Gert B. Aug 31 '21 at 06:07
-
Please add your code line, as what is $categories variable we don't know. By the way, $categories should be an array as whereIn() accept an array as the second parameter. Looking at your if the condition it looks you are passing some value. – Ankit Tiwari Aug 31 '21 at 06:24
1 Answers
1
Remove get()
from the top query, put it after your whereIn
:
$articles = $articles->get();

matiaslauriti
- 7,065
- 4
- 31
- 43

SirMissAlot
- 120
- 2
- 11