NOTIFIABLE NOT WORKING, Cannot access offset of type MongoDB\BSON\ObjectId in isset or empty in
masterbater opened this issue · comments
Jason commented
- 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;
}
}
Jason commented
Removing this fix it
public function getIdAttribute($value = null)
{
return $value;
}