Home > Software design >  How to execute an IF url or route contains ... function with LARAVEL 5
How to execute an IF url or route contains ... function with LARAVEL 5

Time:03-10

I use Laravel 5 for one of my projets and after hours spend I'm asking for little help!!

I need to execute a Script (Google Gtag) if the user is on this exact url :

https://website.com/offer/payment/success/[dynamic]

or/and comes from:

https://checkout.stripe.com/pay/[dynamic]

I tried this without succes:

@if(!Request::is('offer/payment/success/*'))
....
@endif

Does someone can help me ?

CodePudding user response:

You can use str_contains() for this purpose.The str_contains() function checks whether the string (parameter #1) contains the second string.

@if(str_contains(url()->current(), 'offer/payment/success/*'))
     ........
@endif

As per official documentation details of url()->current().

  • Related