J
J
jazzus2019-02-22 14:39:53
Laravel
jazzus, 2019-02-22 14:39:53

How to write differently?

The code

@if (!Request::is('razdel/*') and !Request::is('razdel'))
     ...
    @endif

Can it be written differently? To avoid duplicates.
Task: you need to exclude the code in the blade template if the current address is razdel with all subaddresses

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jazzus, 2019-02-22
@jazzus

It turns out there is a way

@if (!Request::is('*razdel*'))
 ...
@endif

Second option as @Koteezy suggested
@if (!str_contains(Request::path(), 'razdel'))
     ...
@endif

A
Alex Wells, 2019-02-22
@Alex_Wells

https://rachidlaasri.com/php/laravel/macro/2018/04...
If you really need it so much, although for the sake of such a trifle I would not invent something.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question