class Article extends Model
{
protected $fillable = ['category_id','author_id','title','img','description','text'];
public function user()
{
return $this->belongsTo('App\User');
}
public function article_category()
{
return $this->belongsTo('App\ArticleCategory');
}
}
class ArticleCategory extends Model
{
protected $table = 'article_categories';
protected $fillable = ['name','hide'];
public function article()
{
return $this->hasMany('App\Article');
}
}
User model
public function article()
{
return $this->hasMany('App\Article');
}
Why am I getting error when trying to get author name and article category name?
Trying to get it in view this way: $article->user->name $article->article_category->name
Can't understand the reason :c
via Batmannn