I am using a forelse statement on a table as:
@forelse($message->content->suggestions as $suggestion)
<td>
@foreach ($message->content->suggestions as $suggestion)
<span class='badge badge-info'>{{($suggestion->reply->text)}}</span>
@endforeach
</td>
@empty
<em> - </em>
@endforelse
My goal is to check if the table has data called suggestions then run the foreach() however if it's empty just show "-" this is my first time using forelse and wanted to learn it :) If I can't do it this way can someone share how to do it with IF statement instead?
Can you see what I am doing wrong, if I open a table without suggestions I just get a error instead of "-"
Table giving error looks like:
"id" => "3d0ef00c-0edd-4d8b-ad1c-27e92e29c469"
"method" => "rcs"
"msisdn" => 64224603
"direction" => "mt"
"type" => "text"
"status" => "delivered"
"content" => "{"text":"Dial a number"}"
"suggestion_id" => null
"created_at" => 1591669329
"updated_at" => 1591669333
"deleted_at" => null