2019-02-18 07:30:40 +00:00
|
|
|
<?php
|
2018-07-31 07:50:54 +00:00
|
|
|
|
|
|
|
|
namespace Webkul\User\Repositories;
|
2019-02-18 07:30:40 +00:00
|
|
|
|
2018-07-31 07:50:54 +00:00
|
|
|
use Webkul\Core\Eloquent\Repository;
|
|
|
|
|
|
|
|
|
|
class RoleRepository extends Repository
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Specify Model class name
|
|
|
|
|
*
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
function model()
|
|
|
|
|
{
|
2019-02-18 07:30:40 +00:00
|
|
|
return 'Webkul\User\Contracts\Role';
|
2018-07-31 07:50:54 +00:00
|
|
|
}
|
2021-01-13 05:57:12 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update method.
|
|
|
|
|
*
|
|
|
|
|
* @param array $data
|
|
|
|
|
* @param int $id
|
|
|
|
|
*
|
|
|
|
|
* @return \Webkul\User\Model\Role
|
|
|
|
|
*/
|
|
|
|
|
public function update(array $data, $id)
|
|
|
|
|
{
|
|
|
|
|
/* making collection for ease */
|
|
|
|
|
$requestedData = collect($data);
|
|
|
|
|
|
|
|
|
|
/* updating role data */
|
|
|
|
|
$role = $this->find($id);
|
|
|
|
|
$role->name = $requestedData['name'];
|
|
|
|
|
$role->description = $requestedData['description'];
|
|
|
|
|
$role->permission_type = $requestedData['permission_type'];
|
|
|
|
|
$role->permissions = $requestedData->has('permissions') ? $requestedData['permissions'] : [];
|
|
|
|
|
$role->update();
|
|
|
|
|
|
|
|
|
|
/* returning updated role */
|
|
|
|
|
return $role;
|
|
|
|
|
}
|
2018-07-31 07:50:54 +00:00
|
|
|
}
|