Skip to content

Commit

Permalink
Added tag to the config files and updated the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
santigarcor committed Feb 10, 2017
1 parent fe68a89 commit 1e51513
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 31 deletions.
21 changes: 1 addition & 20 deletions docs/configuration/after_installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Set the proper values in the ``config/auth.php``. These values will be used by l

You can also publish the configuration for this package to further customize table names and model namespaces.

Use ``php artisan vendor:publish``, the ``laratrust.php`` and ``laratrust_seeder.php`` files will be created in your ``app/config`` directory.
To change the configuration of laratrust you can change the values inside the ``config/laratrust.php`` file.

Automatic setup (Recommended)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -28,22 +28,3 @@ And then do not forget to run::

.. IMPORTANT::
**If you did the steps above you are done with the configuration, if not, please read and follow the whole configuration process**

Migrations
^^^^^^^^^^

Now generate the Laratrust migration::

php artisan laratrust:migration

It will generate the ``<timestamp>_laratrust_setup_tables.php`` migration.
You may now run it with the artisan migrate command::

php artisan migrate

After the migration, four new tables will be present:

* ``roles`` — stores role records
* ``permissions`` — stores permission records
* ``role_user`` — stores `many-to-many <https://laravel.com/docs/eloquent-relationships#many-to-many>`_ relations between roles and users
* ``permission_role`` — stores `many-to-many <https://laravel.com/docs/eloquent-relationships#many-to-many>`_ relations between roles and permissions
1 change: 1 addition & 0 deletions docs/configuration/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ Configuration
.. toctree::

after_installation
migrations
models/index
seeder
19 changes: 19 additions & 0 deletions docs/configuration/migrations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Migrations
==========

Now generate the Laratrust migration::

php artisan laratrust:migration

It will generate the ``<timestamp>_laratrust_setup_tables.php`` migration.
You may now run it with the artisan migrate command::

php artisan migrate

After the migration, five new tables will be present:

* ``roles`` — stores role records
* ``permissions`` — stores permission records
* ``role_user`` — stores `many-to-many <https://laravel.com/docs/eloquent-relationships#many-to-many>`_ relations between roles and users
* ``permission_role`` — stores `many-to-many <https://laravel.com/docs/eloquent-relationships#many-to-many>`_ relations between roles and permissions
* ``permission_user`` — stores `many-to-many <https://laravel.com/docs/eloquent-relationships#many-to-many>`_ relations between users and permissions
37 changes: 31 additions & 6 deletions docs/configuration/seeder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ And in the ``database/seeds/DatabaseSeeder.php`` file you have to add to the ``r
$this->call(LaratrustSeeder::class);
.. NOTE::
If you **have not** run ``php artisan vendor:publish`` you should run it in order to customize the roles, modules and permissions in each case.
If you **have not** run ``php artisan vendor:publish --tag="laratrust"`` you should run it in order to customize the roles, modules and permissions in each case.

After you run ``php artisan vendor:publish``, you will have a ``config/laratrust_seeder.php`` file and it looks like this:
Your ``config/laratrust_seeder.php`` file looks like this:

.. code-block:: php
Expand All @@ -39,10 +39,15 @@ After you run ``php artisan vendor:publish``, you will have a ``config/laratrust
'profile' => 'r,u'
],
],
'permission_structure' => [
'cru_user' => [
'profile' => 'c,r,u'
],
],
...
];
To understand the file you must know:
To understand the ``role_structure`` you must know:

* The first level is the roles.
* The second level is the modules.
Expand All @@ -53,9 +58,29 @@ With that in mind, you should arrange your roles, modules and permissions like t
.. code-block:: php
return [
'role' => [
'module' => 'permissions',
],
'role_structure' => [
'role' => [
'module' => 'permissions',
],
]
];
To understand the ``permission_structure`` you must know:

* The first level is the users.
* The second level is the modules.
* The second level assignments are the permissions.

With that in mind, you should arrange your users, modules and permissions like this:

.. code-block:: php
return [
'permission_structure' => [
'user' => [
'module' => 'permissions',
],
]
];
Permissions
Expand Down
6 changes: 5 additions & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ Installation

'Laratrust' => Laratrust\LaratrustFacade::class,

4. If you are going to use :doc:`usage/middleware` (requires Laravel 5.1 or later) you also need to add the following to ``routeMiddleware`` array in ``app/Http/Kernel.php``::
4. Run the next command to publish all the configuration files::
php artisan vendor:publish --tag="laratrust"

5. If you are going to use :doc:`usage/middleware` (requires Laravel 5.1 or later) you also need to add the following to ``routeMiddleware`` array in ``app/Http/Kernel.php``::

'role' => \Laratrust\Middleware\LaratrustRole::class,
'permission' => \Laratrust\Middleware\LaratrustPermission::class,
Expand Down
2 changes: 1 addition & 1 deletion docs/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ In order to upgrade from Laratrust 3.0 to 3.1 you have to follow these steps:

'permission_user_table' => 'permission_user',

4. Run ``php artisan laratrust:upgrade`` in order to create the migration with the database upgrade.
4. Run ``php artisan laratrust:upgrade`` to create the migration with the database upgrade.

5. Run ``php artisan migrate`` to run the migration created in the las step.

Expand Down
6 changes: 3 additions & 3 deletions src/Laratrust/LaratrustServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public function boot()
{
// Register published configuration.
$this->publishes([
__DIR__.'/../config/config.php' => app()->basePath() . '/config/laratrust.php',
__DIR__.'/../config/laratrust_seeder.php' => app()->basePath() . '/config/laratrust_seeder.php',
]);
__DIR__.'/../config/config.php' => config_path('laratrust.php'),
__DIR__.'/../config/laratrust_seeder.php' => config_path('laratrust_seeder.php'),
], 'laratrust');

if (class_exists('\Blade')) {
$this->registerBladeDirectives();
Expand Down

0 comments on commit 1e51513

Please sign in to comment.