dimanche 7 février 2021

How to judge if current url is valid in Laravel?

What I want to do

laravel/routes/web.php

Route::get('sample', 'SampleController@index');

In this case, http://localhost:8000/sample is valid.

But http://localhost:8000/test is not valid because it's not defined.

I wanna judge if current url is valid.


Current Code

return \Route::current() ? true : false;

It looks like working, but \Route::current() returns \Illuminate\Routing\Route.

It doesn’t return null.

I guess there are better ways than this.

I would appreciate it if you could give me any advice:)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire