Refactor and add importer to Installer module #443 (#444)

* Refactor and add importer to Installer module #443

* Refactor for finances to use in import

* Import groups into roles

* Formatting

* Formatting

* Add interface in installer for import

* Notes about importing

* Check for installer folder

* Formatting

* Fix pirep->user mapping

* Unused import

* Formatting
This commit is contained in:
Nabeel S
2019-11-27 09:19:20 -05:00
committed by GitHub
parent f95a3f336b
commit 50dc79bc8d
76 changed files with 2753 additions and 1431 deletions

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Services;
use App\Contracts\Service;
use App\Models\Role;
use App\Repositories\RoleRepository;
class RoleService extends Service
{
private $roleRepo;
public function __construct(RoleRepository $roleRepo)
{
$this->roleRepo = $roleRepo;
}
/**
* Update a role with the given attributes
*
* @param Role $role
* @param array $attrs
*
* @return Role
*/
public function updateRole(Role $role, array $attrs)
{
$role->update($attrs);
$role->save();
return $role;
}
/**
* @param Role $role
* @param array $permissions
*/
public function setPermissionsForRole(Role $role, array $permissions)
{
// Update the permissions, filter out null/invalid values
$perms = collect($permissions)->filter(static function ($v, $k) {
return $v;
});
$role->permissions()->sync($perms);
}
}