matched() public static method

Register a route matched event listener.
public static matched ( string | callable $callback ) : void
$callback string | callable
return void
Example #1
0
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
Route::matched(function ($route, $request) {
    $isInstalling = false;
    $config = app('siteConfig');
    //If is install route, skip config check
    if ($route->getName() == Config::get('app-installer::routeName')) {
        $isInstalling = true;
    }
    if (!Config::get('database') && !$isInstalling) {
        die(Response::configurationError("Seems like you are starting up! Go on. Install it! Refer to documentation for instructions.", "Installation not completed"));
    }
    //If config is empty and if the user is not running the installer, Show error
    if (!$config && !$isInstalling) {
        if (!DB::connection()) {
            return Response::configurationError("Oops! The database cant be read!", "Database Connection error");
        } else {
            return Response::configurationError("Oops! The database is not configured properly!", "Database Configuration error");
        }
    }
});
App::before(function ($request) {
    //dd($request->getPathInfo() == route(Config::get('app-installer::routeName'), [], false));
    App::singleton('siteConfig', function () {
        //Loading config
        $config = array(0);
        try {
Example #2
0
File: routes.php Project: lud/club
    if (Session::token() != Input::get('_token')) {
        throw new Illuminate\Session\TokenMismatchException();
    }
});
/*
|--------------------------------------------------------------------------
| Routes
|--------------------------------------------------------------------------
|
| Theese are all the routes defined by the Club package.
*/
Route::group(array('prefix' => Config::get('club::prefix'), '__club' => true), function () {
    $controller = Config::get('club::controller');
    // @todo get rid of names on POST routes ?
    Route::get('signup', array('uses' => $controller . '@getSignup', 'as' => 'club.signup'));
    Route::post('signup', array('uses' => $controller . '@postSignup', 'as' => 'club.signup'));
    Route::get('login', array('uses' => $controller . '@getLogin', 'as' => 'club.login'));
    Route::post('login', array('uses' => $controller . '@postLogin', 'as' => 'club.login'));
    Route::get('lost-password', array('uses' => $controller . '@getLostPassword', 'as' => 'club.lost_password'));
    Route::post('lost-password', array('uses' => $controller . '@postLostPassword', 'as' => 'club.lost_password'));
    Route::get('reset-password/{token}', array('uses' => $controller . '@getResetPassword', 'as' => 'club.reset_password_access'));
    Route::post('reset-password', array('uses' => $controller . '@postResetPassword', 'as' => 'club.reset_password_process'));
    Route::get('logout', array('uses' => $controller . '@getLogout', 'as' => 'club.logout'));
    // email confirmation not implemented
    // Route::get	('signup/confirm/{token}',	['uses' => $controller.'@getConfirm', 'as'=>'club.confirm']);
});
// On every GET request to a named route, this handler flashes the route name.
// If the route name is in the config array club::stay_on_page_routes, the user
// will be redirected to the same url if he/she logs in/out
Route::matched('\\Lud\\Club\\Club@setupStayOnPage');