mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

Home Page:https://www.mongodb.com/compatibility/mongodb-laravel-integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NOTIFIABLE NOT WORKING, Cannot access offset of type MongoDB\BSON\ObjectId in isset or empty in

masterbater opened this issue · comments

  • Laravel-mongodb Version: 4.2
  • PHP Version: 8.3
  • Database Driver & Version:

I think this should string

"id":
[
{
"oid":
"649dafa839c03400146a2b8d"
}
],
{
"notifiables":
{
"class":
"App\Models\User",
"id":
[
{
"oid":
"649dafa839c03400146a2b8d"
}
],
"relations":
[
],
"connection":
"mongodb",
"collectionClass":
null
},
"notification":
{
"deliveryChannels":
[
"mail"
],
"id":
"db3eb1c6-6113-4dad-a9c2-a3503c7284d3"
},
"channels":
[
"mail"
]
}

This is my User Model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Notifications\Notifiable;
use MongoDB\Laravel\Eloquent\Model;

class User extends Model
{
    use HasFactory, Notifiable;
    protected $connection = 'mongodb';
    protected $collection = 'users';
    protected $hidden = ['password', 'deletedAt', 'resetPassword', 'deleted', '__v', 'resetPasswordExpires', 'resetPasswordToken'];
    const CREATED_AT = 'createdAt';
    const UPDATED_AT = 'updatedAt';
    public static $snakeAttributes = false;
    public function getIdAttribute($value = null)
    {
        return $value;
    }


}

See this error from horizon
image

Removing this fix it

 public function getIdAttribute($value = null)
    {
        return $value;
    }