object_type = 'notification_pref'; }); static::updating(function ($model) { $model->object_type = 'notification_pref'; }); // Add global scope to get only notifications static::addGlobalScope('notification', function ($builder) { $builder->where('object_type', 'notification_pref'); }); } public function user() { return $this->belongsTo(User::class, 'user_id'); } public function xprofile() { return $this->belongsTo(XProfile::class, 'user_id', 'user_id'); } }