public function index(User $user, $unread = false)
    {
        $notifications = [];
        $rows = $user->notifications;
        if ($unread) {
            $rows = $user->unreadNotifications;
        }

        foreach ($rows as $k => $notification) {
            $notifications[] = [
                'id'         => $notification->id,
                'created_at' => $notification->created_at->format('l d F H:i'),
                'type'       => $notification->type,
                'message'    => $notification->data['message'],
                'read_at'    => $notification->read_at,
                'user_id'    => $user->id,
            ];
        }

        return json_response($notifications);
    }
public function index(User $user, $unread = false)
    {
        $notifications = [];
        $rows = $user->notifications;
        if ($unread) {
            $rows = $user->unreadNotifications;
        }

        foreach ($rows as $k => $notification) {
            $notifications[] = [
                'id'         => $notification->id,
                'created_at' => $notification->created_at->format('l d F H:i'),
                'type'       => $notification->type,
                'message'    => $notification->data['message'],
                'read_at'    => $notification->read_at,
                'user_id'    => $user->id,
            ];
        }

        return json_response($notifications);
    }
public function index ( User $ user , $ unread = false ) { $ notifications = [ ] ; $ rows = $ user -> notifications ; if ( $ unread ) { $ rows = $ user -> unreadNotifications ; } foreach ( $ rows as $ k => $ notification ) { $ notifications [ ] = [ 'id' => $ notification -> id , 'created_at' => $ notification -> created_at -> format ( 'l d F H:i' ) , 'type' => $ notification -> type , 'message' => $ notification -> data [ 'message' ] , 'read_at' => $ notification -> read_at , 'user_id' => $ user -> id , ] ; } return json_response ( $ notifications ) ; }
Get all the notifications for a user
@param User $user
@param bool $unread
@return array
Get all the notifications for a user