Skip to content

Commit

Permalink
Merge pull request #3 from spatie/main
Browse files Browse the repository at this point in the history
update from main
  • Loading branch information
crossplatformconsulting authored Nov 9, 2024
2 parents 39ed871 + 516e7bd commit ba47df9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to `laravel-permission` will be documented in this file

## 6.10.1 - 2024-11-08

### What's Changed

* Fix #2749 regression bug in `6.10.0` : "Can no longer delete permissions" by @erikn69 in https://github.com/spatie/laravel-permission/pull/2759

**Full Changelog**: https://github.com/spatie/laravel-permission/compare/6.10.0...6.10.1

## 6.10.0 - 2024-11-05

### What's Changed
Expand Down Expand Up @@ -882,6 +890,7 @@ The following changes are not "breaking", but worth making the updates to your a






```
Expand Down Expand Up @@ -952,6 +961,7 @@ The following changes are not "breaking", but worth making the updates to your a






```
Expand Down
4 changes: 2 additions & 2 deletions src/PermissionRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private function getSerializedRoleRelation($permission): array

private function getHydratedPermissionCollection(): Collection
{
$permissionInstance = new ($this->getPermissionClass())();
$permissionInstance = (new ($this->getPermissionClass())())->newInstance([], true);

return Collection::make(array_map(
fn ($item) => (clone $permissionInstance)
Expand All @@ -368,7 +368,7 @@ private function getHydratedRoleCollection(array $roles): Collection

private function hydrateRolesCache(): void
{
$roleInstance = new ($this->getRoleClass())();
$roleInstance = (new ($this->getRoleClass())())->newInstance([], true);

array_map(function ($item) use ($roleInstance) {
$role = (clone $roleInstance)
Expand Down
11 changes: 11 additions & 0 deletions tests/PermissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,15 @@ public function it_is_retrievable_by_id()

$this->assertEquals($this->testUserPermission->id, $permission_by_id->id);
}

/** @test */
public function it_can_delete_hydrated_permissions()
{
$this->reloadPermissions();

$permission = app(Permission::class)->findByName($this->testUserPermission->name);
$permission->delete();

$this->assertCount(0, app(Permission::class)->where($this->testUserPermission->getKeyName(), $this->testUserPermission->getKey())->get());
}
}

0 comments on commit ba47df9

Please sign in to comment.