binshops / laravel-blog

Laravel Blog Package/ Laravel CMS. Easiest way to add a blogging system to your Laravel website. Laravel Blog.
https://www.binshops.com
MIT License
429 stars 134 forks source link

Category Not Displayed Properly #56

Closed scs-ben closed 2 years ago

scs-ben commented 2 years ago

Trying to get the categories for a post to display is not currently possible.

If I dump out the categories I get this data blob: [{"id":2,"created_by":null,"parent_id":null,"lft":1,"rgt":2,"depth":0,"created_at":"2021-12-23T17:32:11.000000Z","updated_at":"2021-12-23T17:32:11.000000Z","pivot":{"post_id":1,"category_id":2}}]

but if I try to iterate over, there is no relationship available to get the category name.

The provided code in categories.blade.php also does not work:


    @foreach($post->categories as $category)
        <a class='btn btn-outline-secondary btn-sm m-1' href='{{$category->url()}}'>
            {{$category->category_name}}
        </a>
    @endforeach```
scs-ben commented 2 years ago

I dug into this and realized that the issue is I need to pull the category name out of the category translations. I'm not sure that the categories.blade.php actually works though.

samberrry commented 2 years ago

Issue fixed with this new update: v9.2.6 Also, you need to change your view files.

scs-ben commented 2 years ago

Thanks!