i need to get comment's that ralation with my post just like real websites
My DB Tables: posts , comments.tags ...
POST model :
public function comments()
{
return $this->belongsTo(Comment::class);
}
public function tags()
{
return $this->belongsTo(Tag::class);
}
....
Comment Model :
public function posts()
{
return $this->hasMany(Post::class);
}
Controller index function
public function index()
{
$posts =Post::all();
return view('rel',compact('posts'));
}
view :
here my output:
as you can see,i have an array with 2 value ( have 2 Post at my table )
and have 2 comment that relation with my post
i need to access to POST field and Comments Field at single page
of course in future i need tag's too
via siros