Answer the question
In order to leave comments, you need to log in
Why is it not displaying data in the foreach loop?
There is a table Items it has id, name, description
$itemRandom = Item::inRandomOrder()
->limit(1)
->get();
$item = $itemRandom[0];
return view('my-form')->with('item',$item);
< p >{{ $item }}< /p >, then I get this
{"ID":9,"NAME":"2FGDSDGDSF","DESCRIPTION":"E1E21E12EASADASF","CREATED_AT":"2018-04-22 17:53:48","UPDATED_AT":"2018-04-22 17:53:48"}
@foreach($item as $items)
<p>
Вашь приз: {{ $items->name }}</br>
Описание:
</p>
@endforeach
"Trying to get property 'name' of non-object
Answer the question
In order to leave comments, you need to log in
$item = Item::inRandomOrder()->first();
return view('my-form',compact('item'));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question