Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
Check Route Prefix in Blade If Loop

I have a route defined like such:

Route::get('aanmelden/{companySlug}/{packageSlug}', ['as' => 'register', 'uses' => 'UsersController@create'])

I want to display some extra plug-in on this specific page, so in the header I want an if loop that checks for the prefix 'register' to display the code.. No luck yet. I tried this:

@if(Request::is('register'))

@if(Request::path() == 'aanmelden')
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

If you want to check route name, do something like this:

@if (Route::currentRouteName() === 'register')

If you want to check if route name starts with register (so it's like prefix), use starts_with() helper:

@if (starts_with(Route::currentRouteName(), 'register'))
about 4 years ago · Santiago Trujillo Report

0

You might also go like:

@if (Route::is('register*'))

which is shorter.

https://laravel.com/docs/5.8/helpers#method-str-is

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!