I have a Vue layout component in which I implement several other Vue components. Among other things also the header. In the header I implement another component called Notification.
I want that when rendering from my header, a get request is made to a specific route and the controller returns data & stores it in the props.notificationdata.
The problem I am having is that I am not getting the data back.
return $data it is not inertia compliant.return back()->with();.Unfortunately I can't find the correct solution....
Here is my Request:
let props = defineProps({
notificationdata: Object,
});
function GetNotificationData() {
props.notificationdata = Inertia.get('/account/user/notifications',
{ preserveState: false, preserveScroll: true }
);
}
Here is the php Function:
static function getUserNotifications() {
$query = Notification::query();
$query->where('state', 0);
$query->orderBy('created_at', 'DESC');
$data = $query->get();
return back()->with(['notificationdata' => $data]);
}