How to redirect to a route in laravel 5 using the href tag if I do not use a blade or any template?

Route::get('/page',' UserController@view page'); 

- my route.

I have a list with the href tag and I want to redirect to this route.

 <ul> <li><a href="">how it works</a></li> </ul> 

I do not use a blade or other patterns.

+7
redirect href laravel-5 routes
source share
2 answers

In the application configuration file, change the url value to localhost/example/public

Then when you want to tie something

<a href="{{ url('page') }}">Some Text</a>

without blade

<a href="<?php echo url('page') ?>">Some Text</a>

+19
source share

In addition to @chanafdo's answer, you can use a route name

when working with a caramel blade

<a href="{{route('login')}}">login here</a> with the parameter in the route name

when go to a url like URI: profile / {id} <a href="{{route('profile', ['id' => 1])}}">login here</a>

without blade

<a href="<?php echo route('login')?>">login here</a>

with a parameter in the route name

when go to a url like URI: profile / {id} <a href="<?php echo route('profile', ['id' => 1])?>">login here</a>

With laravel 5.2 you can use @php @endphp to create <?php ?> In laravel. Using the blade is your personal opinion, but I suggest using it. Get to know him. It has many great features like template inheritance , components and slots , subviews , etc.

+4
source share

All Articles