dimanche 4 mars 2018

Laravel foreach in one collection?

i have an relationship like

+------------+---------+
|    id      | problem |
+------------+---------+
| 1          | problem |    
+------------+---------+


+------------+----------+---------+
|    id      | problemid|solution |
+------------+----------+---------+
| 1          |  1       |solution1|    
+------------+----------+---------+
| 2          |  1       |solution2| 
+------------+----------+---------+

I have done an join and the problem is when i do an foreach in view i get 2 collection with the same problem and 2 different solutions but i need to get the same problem(one problem) and 2 solution.How can i do it?

Here is the code in Controller:

$problem=Problem::select()->join('solution','problem.id','=','solution.problemid')
                            ->where('solution.id',$id)->get();



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2GZiWbW
via IFTTT

Aucun commentaire:

Enregistrer un commentaire