Framework: Need an helper

Created on 2 Jan 2018  路  4Comments  路  Source: laravel/framework

  • Laravel Version: 5.5.0
  • PHP Version: 7

Description:

To make a "is-current" vue, i needed to compare the current url and the one we are. Of course, hard writing the comparison like "recipe/index" is not good, so i thought about using a route ... except that routes return a "/recipe/index?" thing so I tried

substr(route("recipe.index", '', FALSE), 1, -1)

which work great but ... it's a bit heavy don't you think ? Is there a way to have a current_uri('recipe.index') thing ? Like when we use a php artisan route list.

Thank you in advance

All 4 comments

Have you checked any of the existing methods on the Route facade? Route::currentRouteName() sounds relevant, and Route::currentRouteNamed(...$patterns) if you need to check for several names.

if (Route::currentRouteNamed('recipe.index')) {
    // Logic goes here.
}

For more stuff, look at https://laravel.com/docs/5.5/routing#accessing-the-current-route

This repo is for bug tracking. Use the forums or slack channel for solving your issue

@Dylan-DPC Not an issue neither a bug, but a proposition of new functionnality, I'm not sure slack or a forum is well qualified to put it there ...

@Epistol then we have laravel/internals repo for future proposals 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

lzp819739483 picture lzp819739483  路  3Comments

Fuzzyma picture Fuzzyma  路  3Comments

jackmu95 picture jackmu95  路  3Comments

CupOfTea696 picture CupOfTea696  路  3Comments