You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'm using the spatie/laravel-permission package and to track the changes I have created the below pivot model:
<?php
namespace Modules\Auth\Models;
use Illuminate\Database\Eloquent\Relations\MorphPivot;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Activitylog\LogOptions;
final class RoleUser extends MorphPivot
{
use LogsActivity;
public $incrementing = true;
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
->logAll()
->logOnlyDirty();
}
}
And I have the following on my user model:
use LogsActivity, HasRoles {roles as protected spatRoles;}
public function roles(): BelongsToMany
{
return $this->spatRoles()->using(RoleUser::class);
}
The subject_id is populated when a role is assigned to a user, now that I added $incrementing = true, but it is still null when a role is removed from the user.
To Reproduce
Things needed to reproduce the error.
Assign roles to a user, and the subject_id is populated as expected. Remove roles from a user, and the subject_id is null. For example:
Describe the bug
I'm using the spatie/laravel-permission package and to track the changes I have created the below pivot model:
And I have the following on my user model:
The subject_id is populated when a role is assigned to a user, now that I added $incrementing = true, but it is still null when a role is removed from the user.
To Reproduce
Things needed to reproduce the error.
Assign roles to a user, and the subject_id is populated as expected. Remove roles from a user, and the subject_id is null. For example:
Expected behavior
The subject_id should not be null when removing a role from a user.
Versions (please complete the following information)
The text was updated successfully, but these errors were encountered: