-1

I have the following route

Route::get('/{slug}/pd/{public_id}', 'Products\ShowController');

And I want to pass to ShowController just the public_id parameter.

       class ShowController extends Controller
{
        public function __invoke($public_id)
        {
            dd($public_id);
        }
    }

If I run the code above it returns the slug value. I need slug to be just a wildcard in url.

1 Answers1

0

If the slug is certain words in your db, probably you can check route prefix to remove slug from the route. If not, Just ignore the slug after getting it in controller. If its there in route it will be available in controller.

class ShowController extends Controller
{
     public function __invoke($slug, $public_id)
     {
          dd($public_id);
     }
}