A
A
Analka2019-09-06 16:44:46
Laravel
Analka, 2019-09-06 16:44:46

Loading laravel links?

I execute a request to display posts of the selected tag

$tag = Tag::where('slug', $slug)->first();
        $articles = DB::table('articles')
                        ->leftJoin('article_tags', 'articles.id', 'article_tags.article_id')
                        ->select('articles.*')
                        ->where('article_tags.tag_id', $tag->id)
                        ->where('articles.published', '=', 1)->orderBy('articles.view', 'desc')->paginate(15);

in the template I'm trying to display the tags of the corresponding post
@forelse($article->atags as $tag)
    <li><a href="{{route('tagsArticles', $tag->tag->slug)}}">{{$tag->tag->title}}</a></li>
     @empty
@endforelse

but it throws an error
Undefined property: stdClass::$atags (View:post-tag.blade.php)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question