first commit
This commit is contained in:
43
Modules/User/app/Repositories/RoleRepository.php
Normal file
43
Modules/User/app/Repositories/RoleRepository.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Repositories;
|
||||
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class RoleRepository implements RoleInterface
|
||||
{
|
||||
public function pluck()
|
||||
{
|
||||
return Role::pluck('name', 'id');
|
||||
}
|
||||
|
||||
public function findAll()
|
||||
{
|
||||
return Role::with('permissions')->get();
|
||||
}
|
||||
|
||||
public function getRoleById($roleId)
|
||||
{
|
||||
return Role::with('permissions')->findOrFail($roleId);
|
||||
}
|
||||
|
||||
public function delete($roleId)
|
||||
{
|
||||
$role = self::getRoleById($roleId);
|
||||
$role->permissions()->detach();
|
||||
return $role->delete();
|
||||
}
|
||||
|
||||
public function create(array $roleDetails)
|
||||
{
|
||||
return Role::create($roleDetails);
|
||||
}
|
||||
|
||||
public function update($roleId, array $newDetails)
|
||||
{
|
||||
$role = Role::find($roleId);
|
||||
$role->update($newDetails);
|
||||
return $role;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user