Skip to content

Commit 3b76bed

Browse files
authored
Expand incoming type
1 parent bbe5336 commit 3b76bed

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Events/PermissionAttached.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\Permission;
1113

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

18-
public function __construct(public Model $model, public array $permissionIds)
19-
{}
20+
/**
21+
* Internally the HasPermissions trait passes an array of permission ids (eg: int's or uuid's)
22+
* Theoretically one could register the event to other places and pass an Eloquent record.
23+
* So a Listener should inspect the type of $permissionsOrIds received before using.
24+
*
25+
* @param array|int[]|string[]|Permission|Permission[]|Collection $permissionsOrIds
26+
*/
27+
public function __construct(public Model $model, public mixed $permissionsOrIds) {}
2028
}

0 commit comments

Comments
 (0)