Skip to content

Commit 05edc72

Browse files
committed
Update Docs
1 parent add7ed7 commit 05edc72

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
# built documents.
5858
#
5959
# The short X.Y version.
60-
version = u'3.1.0'
60+
version = u'3.2.0'
6161
# The full version, including alpha/beta/rc tags.
62-
release = u'3.1.0'
62+
release = u'3.2.0'
6363

6464
# The language for content autogenerated by Sphinx. Refer to documentation
6565
# for a list of supported languages.

docs/configuration/after_installation.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Configuration Files
66

77
Laratrust now allows mutliple user models, so in order to configure it correctly, you must change the values inside the ``config/laratrust.php`` file.
88

9+
.. _multiple-user-models:
10+
911
Multiple User Models
1012
--------------------
1113

docs/upgrade.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
Upgrade from 3.0 to 3.1
1+
Upgrade from 3.1 to 3.2
22
=======================
33

4-
In order to upgrade from Laratrust 3.0 to 3.1 you have to follow these steps:
4+
In order to upgrade from Laratrust 3.1 to 3.2 you have to follow these steps:
55

6-
1. Change your ``composer.json`` to require the 3.1 version of laratrust::
6+
1. Change your ``composer.json`` to require the 3.2 version of laratrust::
77
8-
"santigarcor/laratrust": "3.1.*"
8+
"santigarcor/laratrust": "3.2.*"
99

1010
2. Run ``composer update`` to update the source code.
1111

12-
3. Add in your ``config/laratrust.php`` file this line::
12+
3. Add in your ``config/laratrust.php`` file this block:
1313

14-
'permission_user_table' => 'permission_user',
14+
.. code-block:: php
1515
16-
4. Run ``php artisan laratrust:upgrade`` to create the migration with the database upgrade.
16+
'user_models' => [
17+
'users' => 'App\User',
18+
],
1719
18-
5. Run ``php artisan migrate`` to apply the migration created in the previous step.
20+
And configure it with you user models information according to the new :ref:`multiple-user-models` explanation.
1921

20-
6. If you use the ``savePermissions`` method in your code, change it to ``syncPermissions``.
22+
4. Run ``php artisan laratrust:add-trait`` to add the ``LaratrustUserTrait`` to the user models.
2123

22-
Now you can use the 3.1 version without any problem.
24+
5. Run ``php artisan laratrust:upgrade`` to create the migration with the database upgrade.
25+
26+
6. Run ``php artisan migrate`` to apply the migration created in the previous step.
27+
28+
Now you can use the 3.2 version without any problem.

docs/usage/concepts.rst

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,19 @@ Now we can check for roles and permissions simply by doing:
139139
$user->hasRole('admin'); // true
140140
$user->can('edit-user'); // false
141141
$user->can('create-post'); // true
142-
$user->hasPermission('create-post'); // true
143-
$user->isAbleTo('create-post'); // true
144142
145143
.. NOTE::
146-
The ``can``, ``hasPermission`` and ``isAbleTo`` methods have the same objective, to check user's permissions.
144+
If you want, you can use the ``hasPermission`` and ``isAbleTo`` methods instead of the ``can`` method.
147145

148-
Inside Laratrust code the ``hasPermission`` method is used intead of the ``can`` method, so if you want to use the Authorizable trait you can use it without any problem (if you didn't use the Laratrust can method). To use the Authorizable trait check :ref:`troubleshooting`.
146+
.. NOTE::
147+
If you want to use the Authorizable trait alongside Laratrust please check :ref:`troubleshooting`.
149148

150-
Both ``hasRole()``, ``can()``, ``hasPermission()``, ``isAbleTo()`` can receive an array of roles & permissions to check:
149+
Both ``hasRole()`` and ``can()`` can receive an array of roles & permissions to check:
151150

152151
.. code-block:: php
153152
154153
$user->hasRole(['owner', 'admin']); // true
155154
$user->can(['edit-user', 'create-post']); // true
156-
$user->hasPermission(['edit-user', 'create-post']); // true
157-
$user->isAbleTo(['edit-user', 'create-post']); // true
158155
159156
By default, if any of the roles or permissions are present for a user then the method will return true.
160157
Passing ``true`` as a second parameter instructs the method to require **all** of the items:
@@ -165,8 +162,6 @@ Passing ``true`` as a second parameter instructs the method to require **all** o
165162
$user->hasRole(['owner', 'admin'], true); // false, user does not have admin role
166163
$user->can(['edit-user', 'create-post']); // true
167164
$user->can(['edit-user', 'create-post'], true); // false, user does not have edit-user permission
168-
$user->hasPermission(['edit-user', 'create-post'], true); // false, user does not have edit-user permission
169-
$user->isAbleTo(['edit-user', 'create-post'], true); // false, user does not have edit-user permission
170165
171166
You can have as many \ ``Role``\s as you want for each ``User`` and vice versa.
172167

@@ -180,7 +175,10 @@ The ``Laratrust`` class has shortcuts to both ``can()`` and ``hasRole()`` for th
180175
// is identical to
181176
182177
Auth::user()->hasRole('role-name');
183-
Auth::user()->can('permission-name');
178+
Auth::user()->hasPermission('permission-name');
179+
180+
.. WARNING::
181+
There aren't ``Laratrust::hasPermission`` or ``Laratrust::isAbleTo`` facade methods, because you can use the ``Laratrust::can`` even when using the ``Authorizable`` trait.
184182

185183
You can also use placeholders (wildcards) to check any matching permission by doing:
186184

0 commit comments

Comments
 (0)