StocksNew/Modules/User/app/Repositories/RoleRepository.php
Sampanna Rimal 53c0140f58 first commit
2024-08-27 17:48:06 +05:45

44 lines
854 B
PHP

<?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;
}
}