php - Laravel returning multiple views -


I am trying to return several views using the Laravel Framework. When I return the variable, it does this only through the loop only, so only a comment is displayed on the page.

  foreach ($ index_comments as $ comments) {$ comment note = $ comments-> Comment; $ Index_children = NULL; $ GetUser = DB :: table ('user') - & gt; Where ('id', '=', $ comments-> by_user_id) - & gt; get (); Forex Currency ($ user $ $ as user) {$ firstName = $ user- & gt; first name; $ Last name = $ user- & gt; last name; } See Return: Creating ('Feeds Dotmates') - & gt; With (Arai ('first name' = & gt; $ first name, 'last name' = & gt; $ last name, 'comment comment' = & gt; $ comment comment, 'index_children' = & gt; $ index_children)); }  

I would like a way to get back many views. Thanks for any help! Toby.

It seems that you do not understand the concepts of Laravel and / or PHP yet. So we start with it from scratch: we want to get all the comments, want to output the comment, and the user's name writing the comment.

  Public function show comments () {$ commentData = DB :: table ('Comments') at very basic level, ) - & gt; Join ('user', 'users.id', '=', 'comments.from_user_id') - & gt; Receive (['text', 'first name', 'last name']); See Return: Creating ('Feeds Dotsmans') - & gt; (In the form of 'comment comment', $ comment data)}  

and in your opinion:

  @forac ($ comment $ $ comment) {{ $ Comment-> Text}} & lt; Br / & gt; {{$ Comment-> First name}} written by {{$ comment-> LastName}} & lt; Hr / & gt; @edennecha  

This is that you do not return views on each iteration, Vision is in the scene. The return statement function ends immediately after execution. If you return to any loop, then it will always go out on first walk, this is the reason that you are getting only one result.

In the next step, you should play with the model for more powerful and readable data handling.


Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

class - Kivy: how to instantiate a dynamic classes in python -

python - mayavi mapping a discrete colorbar on a surface -