D
D
dura2282018-04-30 14:38:05
Laravel
dura228, 2018-04-30 14:38:05

How to form a link in the blade template so that the id is in the middle?

For example, there is a link books.local/admin/authors/1/edit
Instead of one, there can be any number that matches the id.
Tried to do that

<a class="btn btn-primary" href="{{url('admin/authors/{$author->id}/edit')}}">Edit</a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yan-s, 2018-04-30
@Yan-s

https://laravel.ru/docs/v5/helpers#url-%D0%B0%D0%B...
https://laravel.com/docs/5.6/urls
It is convenient to use named routes.
In routes:
Then we get the link like this:
Or, if $author is the corresponding model, then even like this:
Get the address of the formhttp://domain.name/аdmin/authors/123/edit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question