Skip to content

Commit

Permalink
Update permission entity to add parent field relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
nguereza-tony committed Jun 26, 2024
1 parent 44900cd commit 9b5fd9d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Auth/Entity/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

use Platine\Orm\Entity;
use Platine\Orm\Mapper\EntityMapperInterface;
use Platine\Orm\Query\Query;
use Platine\Orm\Relation\ForeignKey;

/**
* @class Permission
Expand All @@ -71,5 +73,13 @@ public static function mapEntity(EntityMapperInterface $mapper): void
]);

$mapper->relation('roles')->shareMany(Role::class);
$mapper->relation('parent')->belongsTo(Permission::class, new ForeignKey([
'id' => 'parent_id'
]));


$mapper->filter('parent', function (Query $q, $value) {
$q->where('parent_id')->is($value);
});
}
}

0 comments on commit 9b5fd9d

Please sign in to comment.