Integration with spatie/laravel-activitylog: Log when permission gets assigned to role #2303
Answered
by
erikn69
lucacastelnuovo
asked this question in
Q&A
-
Hi, My project uses both spatie/laravel-permission and spatie/laravel-activitylog. Does somebody know how I would log when permission gets "given" to a role using App\Models\Role.php <?php
namespace App\Models;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Permission\Models\Role as SpatieRole;
class Role extends SpatieRole
{
use LogsActivity;
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
->logOnly(['name'])
->logOnlyDirty()
->dontSubmitEmptyLogs()
->setDescriptionForEvent(fn (string $eventName) => "role.$eventName");
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
erikn69
Jan 16, 2023
Replies: 1 comment 8 replies
-
Maybe overwriting |
Beta Was this translation helpful? Give feedback.
8 replies
Answer selected by
lucacastelnuovo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe overwriting
asignRole
method