Skip to content

Commit 5afc854

Browse files
authored
Expand signature
1 parent ac7dd81 commit 5afc854

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Events/RoleDetached.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Database\Eloquent\Model;
99
use Illuminate\Foundation\Bus\Dispatchable;
1010
use Illuminate\Queue\SerializesModels;
11+
use Illuminate\Support\Collection;
1112
use Spatie\Permission\Contracts\Role;
1213

1314
class RoleDetached
@@ -16,6 +17,12 @@ class RoleDetached
1617
use InteractsWithSockets;
1718
use SerializesModels;
1819

19-
public function __construct(public Model $model, public Role $role)
20-
{}
20+
/**
21+
* Internally the HasRoles trait passes $rolesOrIds as a single Eloquent record
22+
* Theoretically one could register the event to other places with an array etc
23+
* So a Listener should inspect the type of $rolesOrIds received before using.
24+
*
25+
* @param array|int[]|string[]|Role|Role[]|Collection $rolesOrIds
26+
*/
27+
public function __construct(public Model $model, public mixed $rolesOrIds) {}
2128
}

0 commit comments

Comments
 (0)