Skip to content

Instantly share code, notes, and snippets.

@antonioribeiro
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save antonioribeiro/d638763c6950f954533a to your computer and use it in GitHub Desktop.

Select an option

Save antonioribeiro/d638763c6950f954533a to your computer and use it in GitHub Desktop.
Routes By Name

Having a route of

Route::get('user/{id}', ['as' => 'user.profile', 'use' => 'UsersController@profile']);

You can use this method to select all hits on that particular route and count them using Laravel:

return Tracker::logByRouteName('user.profile')
        ->where(function($query)
        {
            $query
                ->where('parameter', 'id')
                ->where('value', 1);
        })
        ->count();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment