Skip to content
Advertisement

How to execute an IF url or route contains … function with LARAVEL 5

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 :

JavaScript

or/and comes from:

JavaScript

I tried this without succes:

JavaScript

Does someone can help me ?

Advertisement

Answer

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

JavaScript

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

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement