I am trying to make a single page of website but i cant passed argument article in view
my controller is:
public function single(Article $article)
{
$article->increment('viewCount');
$comments = $article->comments()->where('approved' , 1)->where('parent_id', 0)->latest()->with(['comments' => function($query) {$query->where('approved' , 1)->latest();}])->get();
return view('Home.articles.single' , compact('article' , 'comments'));
}
and my view is
<div class="subject_head">
<div class="subject_head--title"><h1 class="title">
</h1>
</div>
</div>
but i cant passed article title. and my model is
protected $table='articles';
protected $casts= [
'images'=>'array'
];
protected $fillable= ['title','slug','description','body','images','tags'];
public function comments()
{
return $this->morphMany(Comment::class, 'commentable');
}
public function user()
{
return $this->belongsTo(User::class);
}
i passed this and while used
$article->all()
this passed all data
$article->title
this method is null
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire