Something like:
[code] $url = route('viewItem', array(123,'Name-Of-The-Item')); [/code]
Hi,
Yes that would give the URL a Name but it doesn't force a name on the url. For example, i visit my site domain.com/p/{id} How do i force a name after the id. like domain.com/p/{id}/{name}
route('viewItem', array('id' => 1,'name' => 'Name-Of-The-Item'));
Yes that would give the URL a Name but it doesn't force a name on the url.
It doesn't force because you have a question mark in route definition just after "name".
smth like this maybe?
Route::get('produk/{category}/{id}/{slug?}', function($category,$id,$slug='')
{
if (!$category)
return Response::view('errors', array(), 404);
if ($id){
$content = getDetailProduk($id); //
return View::make('produkDetail', array('detail' => $content));
}else{
$cats = getCategory($category);
return View::make('produk', array('post' => $cats))
}
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community