K
K
kupurim2018-06-25 21:51:15
Laravel
kupurim, 2018-06-25 21:51:15

How to add domain to route() function?

Hello.
How can I add a domain to the route function with little bloodshed?
For example, I call it like this:

<a href="{{ route('page', $page->link) }}">{{ $page->h1_text }}</a>

And it turns out: And I need something like this: Can you tell me how to do it?
<a href="/page.html">page</a>
<a href="https://site.com/page.html">page</a>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yan-s, 2018-06-25
@kupurim


The third parameter of route is (bool) absolute

By default, the route function generates an absolute URL. If you wish to generate a relative URL, you may pass false as the third argument:
$url = route('routeName', ['id' => 1], false);

O
Oleg, 2018-06-25
@402d

Your question is related to the twig template engine. See https://twig.symfony.com/doc/2.x/advanced.html
for ways to modify/override it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question