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
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)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community