I'm using the controller functionality of Laravel 5 as follows:
Route::controller('somename', '\App\Http\Controllers\SomeController', [
'someMethod' => 'some.name'
]);
class SomeController extends Controller {
public function getSomeMethod($param) {
}
}
Now I would like to execute that method through some ajax request from a blade template. For this I'm using the jQuery ajax method as follows:
$.ajax({
dataType: 'json',
url: laroute.route('some.name', {param: 'someValue'})
});
This will not work because 'param' is not a bound parameter. If I use:
$.ajax({
dataType: 'json',
url: laroute.route('some.name', {one: 'someValue'})
});
it works. How can I name the parameter (while still using Route::controller
) so that laroute also knows about the name of the parameter and I won't have to use one
, two
, three
as parameter name?
Route::controller does not support this kind of parameter binding. You shouldn't use Route::controller anymore as it will be removed in Laravel 5.2.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.