I have web app, the app 50% use ajax for making request
And I want to combine ajax routes into one. Example :
I have routes like this
Route::prefix('post')
->middleware(['verify_origin', 'only_ajax'])
->name('post.')
->group(function() {
Route::post('save-user-profile', 'User\ProfileSettingController@updateProfile')->name('saveUserProfile');
Route::post('save-user-social-media', 'User\ProfileSettingController@updateSocialMedia')->name('saveUserSocialMedia');
Route::post('save-user-avatar', 'User\ProfileSettingController@updateAvatar')->name('saveUserAvatar');
Route::post('save-user-account', 'User\AccountSettingController@updateAccount')->name('saveUserAccount');
});
I want to wrap, all method on post
prefix to one controller
Like this
function handlePost($method) {
call_user_func($method);
}
Usage : handlePost('saveUserProfile')
Above, the method use call action saveUserProfile
, the method saveUserProfile
using validation class.
How to call method, but still use validation class
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire