Sid Heart Sid Heart - 1 year ago 75
PHP Question

How to show my only Blog Who related with tags

i am using This package for tag my blog my Laravel 5.2 App

now i want to show only that blog who related with tag
i am trying to do like this here is my route.php

Route::get('blog/category/{category}', [
'uses' => 'BlogController@categoryindex',
'as' => 'category.index'

Here is my controller

public function categoryindex($slug){

$blogs = blog::where('normalized', $slug)->withAnyTags();

return view('blog.categoryindex', compact('blogs'));


Here is my blog.categoryindex.blade.php

@foreach($blogs as $blog)
<h1>{{ $blog->title }}</h1>

but its won't work

Answer Source

I haven't used this package - nor have I tested, but based on the documentation, I think you're looking for this:

$blogs = Blog::withAnyTags($slug)->get(); //this is correct

@foreach($blogs as $blog)
    <h1>{{ $blog->title }}</h1>

It'd be helpful is you dd($blogs) and show me the result.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download