Database Notifications stored with Unix Timestamp #48720
-
Hey everyone! The project I'm working on stores all timestamps as Unix timestamps. We also us a custom wrapper around Carbon (that we call "Nitrogen") that does some date & translation specific things for our project. All of our timestamps are stored as Unix timestamps and are cast using our custom class. Our <?php
namespace App\Models;
use App\Casts\NitrogenCast;
use \Illuminate\Database\Eloquent\Model as EloquentModel;
class Model extends EloquentModel {
protected $dateFormat = 'U';
protected $casts = [
'created_at' => NitrogenCast::class,
'updated_at' => NitrogenCast::class,
];
} I'm implementing notifications in my project, and I'd like to do similar things with DatabaseNotifications stored in the "notifications" table. Any ideas how I could do that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I think making a model that extends DatabaseNotification src/Illuminate/Notifications/DatabaseNotification.php like |
Beta Was this translation helpful? Give feedback.
Because of using Notifiable trait in models like User model, I think that trait needs to be extended or overriding to consider your
DatabaseNotification
model. And then we can use that trait instead of default one.I didn't test this scenario, but it is good idea if you check the src/Illuminate/Notifications/HasDatabaseNotifications.php you can see the trait is using default
DatabaseNotification
and so it can be overridden.