Skip to content

Commit

Permalink
added gettings roles features
Browse files Browse the repository at this point in the history
  • Loading branch information
nahid committed Feb 27, 2018
1 parent 550d376 commit d247919
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,4 +457,25 @@ public function getAbilities($module = null)

return null;
}

/**
* get all roles
*
* @return mixed
*/
public function roles()
{
return $this->permission->getRoles();
}

/**
* getting a single role
*
* @param $role
* @return mixed
*/
public function role($role)
{
return $this->permission->getRole($role);
}
}
1 change: 1 addition & 0 deletions src/Permissions/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ public function getPermissionArrayAttribute()
{
return json_to_array($this->permission);
}

}
22 changes: 22 additions & 0 deletions src/Permissions/PermissionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,26 @@ public function syncRolePermissions($role, array $data)

return $this->model->insert($data);
}


/**
* get all roles
*
* @return mixed
*/
public function getRoles()
{
return $this->model->all();
}

/**
* getting a single role
*
* @param $role
* @return mixed
*/
public function getRole($role)
{
return $this->model->where('role_name', $role)->first();
}
}
1 change: 1 addition & 0 deletions src/Users/Permitable.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ public function permission()
{
return $this->belongsTo('Nahid\Permit\Permissions\Permission', config('permit.users.role_column'), 'role_name');
}

}

0 comments on commit d247919

Please sign in to comment.