dimanche 19 avril 2015

Using 2 tables in a laravel forelse loop

How can i go about using two tables to feed data into a forelse loop. Im using sqlite.This is what i have so far.


function that selects data:



function statusAndcomments($id)
{
$sql = "Select * FROM status, comment WHERE user_Id = ?";
$results = DB::select($sql, array($id));

return $results;
}


Route



Route::get('comments_post/{id}', function($id)
{
$results = statusAndcomments($id);
return View::make('Social.comments_post')->withComments($results);
});


Code that uses sqlite query



@forelse ($comments as $comment)
<div class="panel panel-default">

<div class="panel-heading">{{{ $comment->Name }}} - {{{ $comment->Title }}}</div>
<div class="panel-body">
<img class='ProfilePic' src='../Images/defaultProfile.jpg' alt='Profile Picture'>
<div>
<p>{{{ $comment->Message }}}</p>
</div>
</div>
<div class="panel-footer">
<form method="post" action="{{{ url("commentPoster/$comment->Id") }}}">
<input name ="comment" class="form-control" AUTOCOMPLETE=OFF placeholder="Write a comment...">
</form>
</div>
</div>



<div class="panel panel-default">
<div class="panel-heading">{{{ $comment->comment.name }}}</div>
<div class="panel-body">
<p>{{{ $comment->comment.comment }}}</p>
</div>
<div class="panel-footer"></div>
</div>
@empty
No Posts
@endforelse

Aucun commentaire:

Enregistrer un commentaire