Skip to content

Commit ac7dd81

Browse files
authored
Expand signature
1 parent c08e0f2 commit ac7dd81

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Events/RoleAttached.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@
88
use Illuminate\Database\Eloquent\Model;
99
use Illuminate\Foundation\Bus\Dispatchable;
1010
use Illuminate\Queue\SerializesModels;
11+
use Illuminate\Support\Collection;
12+
use Spatie\Permission\Contracts\Role;
1113

1214
class RoleAttached
1315
{
1416
use Dispatchable;
1517
use InteractsWithSockets;
1618
use SerializesModels;
1719

18-
public function __construct(public Model $model, public array $roleIds)
19-
{}
20+
/**
21+
* Internally the HasRoles trait passes an array of role ids (eg: int's or uuid's)
22+
* Theoretically one could register the event to other places passing other types
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) {}
2028
}

0 commit comments

Comments
 (0)