예제 #1
0
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('login', array('as' => 'login', 'uses' => 'AuthController@showLogin'));
Route::post('login', array('as' => 'login', 'uses' => 'AuthController@postLogin'));
Route::get('logout', array('as' => 'logout', 'uses' => 'AuthController@logOut'));
Route::get('/', array('as' => 'index', 'uses' => 'AuthController@index'));
Route::filter('perfil', function () {
    if (Auth::user()->perfil_id != 1) {
        $permiso = Permiso::where(['perfil_id' => Auth::user()->perfil_id, 'ruta' => Route::current()->getName()])->first();
        if (empty($permiso)) {
            return Redirect::route('index');
        }
    }
});
Route::group(['before' => 'auth|perfil'], function () {
    Route::get('facturas', array('as' => 'facturas', function () {
        return 'Facturas aqui.';
    }));
    Route::get('reportes', array('as' => 'reportes', function () {
        return 'Reportes aqui.';
    }));
    Route::group(array('prefix' => 'clientes'), function () {
        Route::get('/admin', array('as' => 'homeClientes', 'uses' => 'Clientes@home'));
        Route::get('/{id?}', array('as' => 'infoClientes', 'uses' => 'Clientes@index'));