How to print data?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
19 views
@foreach ($post->tags as $tag) {{$tag}}@endforeach


Which brings

[{"id":17,"title":"23525246","created_at":null,"updated_at":null}][{"id":18,"title":"674","created_at":null,"updated_at":null}][{"id":19,"title":"dssdfsdf ","created_at":null,"updated_at":null}][{"id":20,"title":"er","created_at":null,"updated_at":null}]


When you use {{$tag->id}} gives an error

Property [id] does not exist on this collection instance. (View: D:\\OpenServer\\domains\\laravel\esources\\views\\posts\\show.blade.php)
by | 19 views

1 Answer

0 like 0 dislike
Because you have a $tag array of objects.
Do
{{ $tag[0]->id }}
or
{{ $tag->first()->id }}
by

Related questions

0 like 0 dislike
4 answers
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
asked Jun 15, 2019 by Ka4_Piton
0 like 0 dislike
1 answer
asked Jun 3, 2019 by codeturn
0 like 0 dislike
1 answer
asked Jun 8, 2019 by adam_carraway
110,608 questions
257,186 answers
0 comments
36,596 users