Simon Suh
Simon Suh

Reputation: 10882

How do I use route name in a url in Laravel?

php artisan route:list is as follows:

 | GET|HEAD  | posts/{post}/edit | posts.edit    | App\Http\Controllers\PostController@edit        | web      

how do I use the route name 'posts.edit' so that it appears in the blade.php file?

Currently I use the HTML Laravel package and wrote {{ Html::linkRoute('posts.edit', 'Edit', array($post->id), array('class'=>'btn btn-primary btn-block')) }}

but I would like to use plain html in the blade templating engine without HTML Laravel package. Is there a way to utilize the route name 'posts.edit' in the blade file?

Upvotes: 4

Views: 4704

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163748

You usually use it with route() helper:

<a href="{{ route('posts.edit', ['id' => $post->id]) }}">Link</a>

In this case you'll not need to use Laravel Collective HTML package.

Upvotes: 5

Related Questions