Support the ongoing development of Laravel.io →
Requests Input Database
Last updated 1 year ago.
0

Something like:

[code] $url = route('viewItem', array(123,'Name-Of-The-Item')); [/code]

Last updated 1 year ago.
0

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}

Last updated 1 year ago.
0
    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".

Last updated 1 year ago.
0

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))
        }
	
});

source

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.