Support the ongoing development of Laravel.io →
Configuration Packages

i have some problem to make routes in laravel, i have a package then i call from routes it is work fine but i want make it easy with automatic, so i put thi code

Route::any('admin/(:any)/add/(:any?)', function($controller,$params=null) {
  return Controller::call('admin.'.$controller.'@edit', (array) $params);
});

i want call controller with namespace then i change that script with this

Route::any('admin/(:any)/add/(:any?)', function($controller,$params=null) {
  return Controller::call("Ardani\\Smsgateway\\Controllers\\Kirim@simplesms", (array) $params);
});

but error NotFoundHttpException, what wrong my code? edit this my code on routes in package :

Route::any('smsgateway/{controller}/{method?}', function($controller,$method='index',$params=null) {
  	return Controller::call("$controller","Ardani\\Smsgateway\\Controllers\\".$controller."@$method",(array) $params);
});

when this run , show message

Symfony \ Component \ Debug \ Exception \ FatalErrorException Call to undefined method Illuminate\Routing\Controller::call()

i sorry my english not good. thanks before

Last updated 3 years ago.
0

I didnt make any test's and im newbie but i THINK that router use * for anything and 'any' will mean any type (numbers, characters,etc...

And as far as i know we use { } for params, so you could try: 'test/{controller}/add/{params?}'

Im not sure if {params?} will catch everything after add/ or it will catch add/*/ ( * = anything)

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ardani ardani Joined 5 Feb 2014

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.

© 2025 Laravel.io - All rights reserved.