Appearance
Roles
Introduction
Roles
are used to manage Permissions
in intratool.
The binding of Permissions
to a Role
is done by a pivot table called permission_role
, in which each Permission
of the unique Role
is assigned.
Those Roles
will then get assigned to a Department so that every member of a Department has the same Permissions
unless the Permissions
are not modified for a specific User .
All this data can then be retrieved/created or modified via the Roles
API.
Model & Relations
Namespace
App\Role
Relations
Relation | Key | Type | Relation Field(s) |
---|---|---|---|
Users | users | Has many | users.role_id |
Department | department | Belongs to | department_id |
Departments | departments | Has many | departments.role_id |
Departments | infoboard_departments | Belongs to many | Intermediate table |
Permissions | permissions | Belongs to many | Intermediate table |
List
Get a list of all Roles
.
Definition
GET /api/roles
Example Request
php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/roles', [
'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
Example Response
json
[
{
"id": 2,
"name": "Usergroup-1",
"active": 1,
"department_id": 2,
"sort_number": 1,
"created_at": "2019-01-21 13:55:33",
"updated_at": "2019-01-21 13:56:22",
"deleted_at": null,
"department": {
"id": 2,
"name": "Usergroup-1"
},
"permissions": [
{
"id": 1,
"type": "infoboard",
"name": "infoboard-administration-rights",
"description": "Administrationsrechte",
"sort_number": 2
},
{
"id": 12,
"type": "infoboard",
"name": "infoboard-show",
"description": "Infoboard anzeigen",
"sort_number": 1
},
{
"id": 100,
"type": "manual",
"name": "manual-administration-rights",
"description": "Administrationsrechte",
"sort_number": 101
}
]
}
]
Get
Get a single Role
by id
.
Definition
GET /api/roles/{id}
Example Request
php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/roles/3', [
'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
Example Response
json
{
"id": 3,
"name": "Usergroup-2",
"active": 1,
"department_id": 3,
"sort_number": 2,
"created_at": "2019-01-21 13:55:35",
"updated_at": "2019-01-21 13:56:24",
"deleted_at": null,
"department": {
"id": 3,
"name": "Usergroup-2"
},
"permissions": [
{
"id": 12,
"type": "infoboard",
"name": "infoboard-show",
"description": "Infoboard anzeigen",
"sort_number": 1
}
],
"departments": [
{
"id": 3,
"name": "Usergroup-2"
}
],
"infoboard_departments": [
{
"id": 3,
"name": "Usergroup-2"
}
]
}
Create
Create a new Role
.
Definition
POST /api/roles
Request Keys
Key | Type | Default | Description |
---|---|---|---|
department_id * | integer | - | Related Department |
name * | string | - | Name of the Role |
active | boolean | true | Whether the Role active |
permissions_ids * | string | - | The granted Permissions of the Role |
department_ids | string | Related Department | The Departments the Role has access to view content from |
infoboard_department_ids | string | Related Department | The Departments the Role is allowed to assign InfoboardPosts to |
sort_number | integer | Current highest +1 | The index of the Role |
Keys with *
are required.
Example Request
php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/roles', [
'headers' => ['Authorization' => "Bearer {accessToken}"],
'json' => [
'department_id' => 7,
'name' => 'Usergroup-4',
'permission_ids' => '1'
]
]);
Example Response
json
{
"status": "success",
"data": {
"department_id": 7,
"name": "Usergroup-4",
"sort_number": -1,
"active": 1,
"updated_at": "2019-01-24 15:58:18",
"created_at": "2019-01-24 15:58:18",
"id": 5
}
}
Update
Update an existing Role
by id
.
Definition
PUT /api/roles/{id}
Request Keys
Key | Type | Description |
---|---|---|
department_id | integer | Related Department |
name | string | Name of the Role |
active | boolean | Whether the Role active |
permissions_ids | string | The granted Permissions of the Role |
department_ids | string | The Departments the Role has access to view content from |
infoboard_department_ids | string | The Departments the Role is allowed to assign InfoboardPosts to |
sort_number | integer | The index of the Role |
Example Request
php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/roles/5', [
'headers' => ['Authorization' => "Bearer {accessToken}"],
'json' => [
'department_ids' => '2'
]
]);
Example Response
json
{
"status": "success",
"data": {
"id": 5,
"name": "Usergroup-4",
"active": 1,
"department_id": 7,
"sort_number": 4,
"created_at": "2019-01-24 15:58:18",
"updated_at": "2019-01-24 15:58:19",
"deleted_at": null
}
}
Delete
Delete an existing Role
by id
.
Definition
DELETE /api/roles/{id}
Example Request
php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/roles/5', [
'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
Example Response
json
{
"status": "success",
"data": []
}