I have following tables
users
id|username|email|password|
posts
id|post_name|post_content|category_id|user_id|tag_id
categories
id|category_name
comments
id|comment_content|post_id|user_id
tags
id|tag_name
Post Model
class Post extends Model
{
public function comments()
{
return $this->hasMany('App\Comment');
}
public function users()
{
return $this->belongsTo('App\User');
}
public function tags()
{
return $this->belongsToMany('App\Tag');
}
Comment Model
class Comment extends Model
{
public function posts()
{
return $this->belongsTo('App\Post');
}
}
Tag Model
class Tag extends Model
{
public function posts()
{
return $this->belongsToMany('App\Tag');
}
Now my question is how i can access all comments that belong to post with commented username and tags belongs to that posts
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1O1jQo9
via IFTTT
Aucun commentaire:
Enregistrer un commentaire