Trying to get property 'message' of non-object
@foreach($myNotifications as $myNotifications)
@php
/** @var \App\Models\Notification\Notification $myNotifications */
@endphp
<?php echo e($myNotifications->data->message); ?>
@endforeach
with database structure field data:
{"message":"sisa stock Galon merek madinah tersisa 4","status":"Urgent","url":"link"}
CodePudding user response:
My guess is that "data" is encoded json string. You can cast data field to array in model and that will make data->message work.
Add this to Notification model:
protected $casts = [
'data' => 'array',
];