Sithu
Sithu

Reputation: 4862

How can I get a route using dynamic parameters in laravel

I'm new to Laravel. I have a route defined in routes.php

Route::get('article/{id}/{slug}', array('uses' => '....', 'as' => '.....'));

How can I get it using route()? I'm trying this, but failed.

<a href="{{ route('article', $article->id, $article->slug) }}">

Upvotes: 0

Views: 3371

Answers (1)

Sithu
Sithu

Reputation: 4862

I just got a solution using as and array parameter.

Route::get('article/{id}/{slug}', array('uses' => '.....', 'as'=>'article'));

Then, call it from route().

<a href="{{ route('article', array($article->id, $article->slug)) }}">

Upvotes: 1

Related Questions