When I try to display the contents of the date field within a view, I get an error:
Undefined property: stdClass::$show.
$shows = DB::select("SELECT * FROM shows"); ?>
<div class="max-w-2xl p-6 mx-auto ">
@foreach ($shows as $show)
{{-- @dd($show) --}}
<div class="mt-6 p-6 bg-sp_white text-dk_brown shadow-sm rounded-lg">
{{ $show->show-date->format('Y-m-d') }}
{{ $show->venue }} <!-- string -->
{{ $show->description }} <!-- string -->
</div>
@endforeach
</div>
If I remove the date field from the @foreach statement, I get no errors and the string fields are displayed. Also, if I dd($show), I successfully get all expected results.
2
Answers
I reworded the select statement as follows and it works:
Try this