Reputation: 57
In one of my projects I use Laravel. In my view I use:
{{ $intro->inhoud}}
And this returns: Undefined property: Illuminate\Database\Eloquent\Collection::$inhoud (View: D:\Web\Ampps\www\mca.app\resources\views\frontend\huisartsen.blade.php)
However, when I use:
{{ $intro }}
I get the entire intro object, with "inhoud" being one of the keys:
[{"id":1,
"inhoud":"Bacon ipsum dolor amet brisket pork loin hamburger ham tenderloin, spare ribs pork chop meatloaf. Hamburger pig strip steak tri-tip doner pastrami prosciutto picanha shank pork chop. Strip steak rump doner chuck sirloin prosciutto swine andouille picanha landjaeger cupim jerky. Venison tongue rump, tri-tip boudin fatback salami sausage. Capicola boudin kielbasa, tri-tip swine t-bone leberkas corned beef. Sausage meatball chuck, boudin pork belly cow jowl andouille salami turkey.",
"pagina":"huisartsen",
"created_at":null,
"updated_at":null}]
Anyone any idea why I cannot use
{{ $intro->inhoud }}
or even
{{ $intro["inhoud"] }}
Thanks a lot from a starting Laravel developer!
Upvotes: 1
Views: 335
Reputation: 57
Thanks @Burak, thanks to you I found the solution!
The problem was in my controller, where I did this:
$intro = App\Intro::where('pagina', '=', 'huisartsen')->get();
And that gave me an array. By changing it to this:
$intro = App\Intro::where('pagina', '=', 'huisartsen')->first();
It gave me the object I wanted so now I can use
{{ $intro->inhoud }}
Upvotes: 1
Reputation: 7954
Try json_decode($intro)
as it seems to me that this is JSON object
Upvotes: 0