Support the ongoing development of Laravel.io →
posted 8 years ago
Views Blade
Last updated 2 years ago.
0

i would not recommend hard coding route paths in the view, instead use a route name, so you can easily change route path later without changing anything in the templates

Route::get('myProject/public/project/8/about-project', 'method@controllerClass')->name('about-project') 

then in the template

@if(\Request::route()->getName() == 'about-project') 
    @include('projects.projectDetails.aboutProject') 
@endif
0

Thanks @astroanu for you reply but now I have Error:

Call to undefined method Illuminate\Routing\Route::name()

I am using Laravel 4.2

and the Error is coming from this part

->name
0

i think for 4.2 you have to pass it like this

Route::get('myProject/public/project/8/about-project', array('as' => 'about-project', 'uses' => 'method@controllerClass'));
0

also i noticed you're calling public in your route path. make sure the virtual host is pointed to the public folder root not the MyProject folder root, you should be calling 'public/project/8/about-project' not 'myProject/public/project/8/about-project'

0

astroanu said:

i think for 4.2 you have to pass it like this

Route::get('myProject/public/project/8/about-project', array('as' => 'about-project', 'uses' => 'method@controllerClass'));

Yes this worked fine, but still this one not

@if(\Request::route()->getName() == 'about-project') 
    @include('projects.projectDetails.aboutProject') 
@endif

not recognize route()

0

Sign in to participate in this thread!

Eventy

Your banner here too?

johnef johnef Joined 18 May 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.