@camkem try with article.slug only
:href="route('article.show', article.slug)"
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I am hoping someone can help me.
I am wanting to inject a variable into a ziggy route so that it can be used by my controller function.
The variable comes from the page props passed over by the model in the back end.
My controller looks like this
class ArticlesController extends Controller
{
public function index() {
$articles = Article::orderBy('created_at', 'desc')->paginate(10);
return Inertia::render('Frontend/Articles/Index', compact('articles'));
}
public function show($slug)
{
$article = Article::where('slug', $slug)->firstOrFail();
$can_update = Auth::check() ? Auth::user()->can('update', $article) : false;
$can_delete = Auth::check() ? Auth::user()->can('delete', $article) : false;
return Inertia::render('Frontend/Articles/Show', compact('article', 'can_update', 'can_delete'));
}
}
My routes look like this
use App\Http\Controllers\Frontend\ArticlesController as FrontendArticlesController;
Route::get('/articles', [FrontendArticlesController::class, 'index'])->name('articles');
Route::get('/articles/{article:slug}', [FrontendArticlesController::class, 'show'])->name('article.show');
My front end ziggy calling looks like this (its inside a v-for statement to display the articles)
<template
v-for="(article, key) in articles.data"
key="article.id"
>
<link
:href="route('article.show', [article, article.slug])"
>
{{ article.title }}
</link>
</template>
Hopefully someone can assist me with this, thanks in adavnce!!!
needs to be an object
route('article.show', [article, article.slug])
//fixed
route('article.show', {article: article.slug})
Please or to participate in this conversation.