This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Wouter
I'm trying to display a hasmany relation in my component.
My query like:
public function onRender(){
$blogs = BlogPost::where('published', 1)
->where('published_at', 'orderBy($this->property('sortOrderBy'), $this->property('sortOrder'))
->with('tags')
->paginate($this->property('postsPerPage'));
$this->blogs = $blogs;
}
In the html of the component i have a for loop what goes well. Only the tags are a problem. When i set {{ post.tags }} i get a json output. Is this normal or do i something wrong ?
Last updated
Renatio
Yes, this is normal behaviour.
post.tags
is an Eloquent collection, so you should loop it through like posts.
For example:
{% for tag in post.tags %}
{{ tag.name }}{% if not loop.last %}, {%endif %}
{% endfor %}
Last updated
1-3 of 3