Skip to content

Commit

Permalink
Added middleware abort options
Browse files Browse the repository at this point in the history
  • Loading branch information
santigarcor committed Sep 24, 2016
1 parent 35bce05 commit 901cafc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/usage/middleware.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Middleware
==========

Concepts
^^^^^^^^

You can use a middleware to filter routes and route groups by permission or role:

.. code-block:: php
Expand All @@ -27,3 +30,23 @@ For more complex situations use ``ability`` middleware which accepts 3 parameter
.. code-block:: php
'middleware' => ['ability:admin|owner,create-post|edit-user,true']
Middleware Return
^^^^^^^^^^^^^^^^^

The middleware supports two kinds of returns in case the check fails. You can configure the return type and the value in the ``config/laratrust.php`` file.

Abort
-----

By default the middleware aborts with a code ``403`` but you can customize it changing the ``middleware_params`` value.

Redirect
--------

To make a redirection in case the middleware check fails. You will need to change the ``middleware_handling`` value to ``redirect`` and the ``middleware_params`` to the route you need to be redirected. Leaving the configuration like this:

.. code-block:: php
'middleware_handling' => 'redirect',
'middleware_params' => 'home', // Change this to the route you need

0 comments on commit 901cafc

Please sign in to comment.