Skip to content

Commit 2549928

Browse files
committed
Update documentation
1 parent a64d59e commit 2549928

File tree

2 files changed

+98
-12
lines changed

2 files changed

+98
-12
lines changed

CHANGELOG.md

+54
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,60 @@
11
# Change Log
22
[Package Checklist](http://phppackagechecklist.com/#1,2,3,4,6,7,8,9,10,11,12,13,14)
33

4+
## [0.6.0] - 31 May 2018
5+
### Added
6+
- authorization api functionality.
7+
8+
### Updated
9+
- changelog and readme.
10+
11+
## [0.5.10] - 22 Mar 2018
12+
### Fixed
13+
- various controller and view related items (work in progress).
14+
15+
## [0.5.9] - 22 Mar 2018
16+
### Fixed
17+
- policy check in Roles controller.
18+
19+
## [0.5.8] - 16 Mar 2018
20+
### Fixed
21+
- service provider class reference in console command.
22+
23+
## [0.5.7] - 7 Mar 2018
24+
### Fixed
25+
- permission seeder to respect existing records.
26+
27+
## [0.5.6] - 5 Mar 2018
28+
### Fixed
29+
- an edge-case where non-model items were being listened to in listeners.
30+
31+
## [0.5.5] - 10 Feb 2018
32+
### Fixed
33+
- service provider class name.
34+
35+
## [0.5.4] - 10 Feb 2018
36+
### Added
37+
- Laravel 5.6 compatibility.
38+
39+
## [0.5.3] - 3 Feb 2018
40+
### Fixed
41+
- entity management to automatically derive from registered policies.
42+
43+
## [0.5.2] - 3 Feb 2018
44+
### Fixed
45+
- role controller authorization.
46+
47+
## [0.5.1] - 20 Nov 2017
48+
### Updated
49+
- README with more detailed instructions on initial setup on an empty database.
50+
51+
### Fixed
52+
- CreatedListener to detect edge-cases where database may not be migrated fully.
53+
54+
## [0.5.0] - 31 Aug 2017
55+
### Updated
56+
- to work with Laravel 5.5.
57+
458
## [0.4.0] - 4 Jul 2017
559
### Added
660
- Laravel 5.4 compatibility.

README.md

+44-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Provide a simple method of managing ACL in a Laravel application built on the
1818

1919
## Requirements
2020
- PHP >=7.1.3
21-
- Laravel >= 5.4
21+
- Laravel >= 5.5
2222
- Bootstrap 3 (needs to be included in your layout file)
2323
- FontAwesome 4 (needs to be included in your layout file)
2424

@@ -34,23 +34,14 @@ Install via composer:
3434
composer require genealabs/laravel-governor
3535
```
3636

37-
**ONLY FOR LARVEL 5.4 AND LOWER:** Add the service provider to your app.php config file:
38-
```php
39-
'providers' => [
40-
// [...]
41-
GeneaLabs\LaravelGovernor\Providers\Service::class,
42-
// [...]
43-
],
44-
```
45-
4637
## Implementation
4738
1. First we need to update the database by running the migrations and data seeders:
4839
```sh
4940
php artisan migrate
5041
php artisan db:seed --class=LaravelGovernorDatabaseSeeder
5142
```
5243

53-
2. If you are starting out with an empty database, run your seeders now:
44+
2. If you have seeders of your own, run them now:
5445
```sh
5546
php artisan db:seed
5647
```
@@ -73,7 +64,8 @@ composer require genealabs/laravel-governor
7364
class User extends Authenticatable
7465
{
7566
use Governable;
76-
// [...]
67+
// [...]
68+
}
7769
```
7870

7971
### Configuration
@@ -142,6 +134,40 @@ We recommend making a custom 403 error page to let the user know they don't have
142134
https://laravel.com/docs/5.4/errors#custom-http-error-pages for more details on
143135
how to set those up.
144136
137+
### Authorization API
138+
You can check a user's ability to perform certain actions via a public API. It
139+
is recommended to use Laravel Passport to maintain session state between your
140+
client and your backend. Here's an example that checks if the currently logged
141+
in user can create `GeneaLabs\LaravelGovernor\Role` model records:
142+
143+
```php
144+
$response = $this
145+
->json(
146+
"GET",
147+
route('genealabs.laravel-governor.api.user-can.show', "create"),
148+
[
149+
"model" => "GeneaLabs\LaravelGovernor\Role",
150+
]
151+
);
152+
```
153+
154+
This next example checks if the user can edit `GeneaLabs\LaravelGovernor\Role`
155+
model records:
156+
```php
157+
$response = $this
158+
->json(
159+
"GET",
160+
route('genealabs.laravel-governor.api.user-can.show', "edit"),
161+
[
162+
"model" => "GeneaLabs\LaravelGovernor\Role",
163+
"primary-key" => 1,
164+
]
165+
);
166+
```
167+
168+
The abilities `inspect`, `edit`, and `remove`, except `create` and `view`,
169+
require the primary key to be passed.
170+
145171
## Examples
146172
### Config File
147173
```php
@@ -269,3 +295,9 @@ class MyModelPolicy extends LaravelGovernorPolicy
269295
}
270296
}
271297
```
298+
299+
## Update Process
300+
### 0.5 to 0.6
301+
1. If you were extending `GeneaLabs\LaravelGovernor\Policies\LaravelGovernorPolicy`,
302+
change to extend `GeneaLabs\LaravelGovernor\Policies\BasePolicy`;
303+
2. Support for version of Laravel lower than 5.5 has been dropped.

0 commit comments

Comments
 (0)