I would like to capture the url example, /user/**
(everything starting with / user), I'm using laravel and blade, using Request :: url () I get localhost:8000
but I need something that can capture the routes. Thank you
I would like to capture the url example, /user/**
(everything starting with / user), I'm using laravel and blade, using Request :: url () I get localhost:8000
but I need something that can capture the routes. Thank you
To get the url in the view you can do:
<p>{{Request::url()}}</p>
To check if the second segment of the url has "user":
@if(explode('/', Request::url())[3] == 'user')
// tem '/user'
@endif
Sending this from the controller might be a better idea:
public function logout(Request $request) {
if($request->segments()[0] == 'user') {
// url tem como primeiro segmento "user"
}
}
Still other possible solution , without having tested, sorry if it does not work:
if (Request::is('user/*'))
{
// code
}
I do this on the blade:
//http://localhost:8000/user/teste
//Pegar o primeiro que é "user"
Request::segment(1)
//Pegar o segundo é "teste"
Request::segment(2)
It already ignores the default URL and takes the route directly.
In case to check if it starts with "user" you would do so on the blade:
{{ Request::segment(1) == 'user' ? 'verdadeiro' : 'falso' }}
Or:
@if(Request::segment(1) == 'user')
//Suas instruções aqui
@endif