Pooria Khodaveissi
Pooria Khodaveissi

Reputation: 395

How to Accress Route in another namespace?

I have a namespace like foo/bar I have added this line:

use Illuminate\Routing\Route;

but still getting this error *

Symfony\Component\Debug\Exception\FatalErrorException thrown with message "Call to undefined method Illuminate\Routing\Route::current()"

*

Upvotes: 1

Views: 529

Answers (1)

Pooria Khodaveissi
Pooria Khodaveissi

Reputation: 395

Ok, newbie mistake, first of all if you put the line

use Illuminate\Routing\Route;

you won't be able to call your methods, you'll get the error: Laravel Non-static method second of all to access method Route::currentRouteName(), the namespace is wrong and Illuminate\Routing\Router is the correct one,

at the end you should make use of the facade like so:

Illuminate\Support\Facades\Route

Happy Coding YA'LL

Upvotes: 1

Related Questions