I have many "version" or modules in the laravel source code. Organized into subfolders inside the App\Http\Controllers e.g App\Http\Controllers\module1
The "base" controllers are in App\Http\Controllers and the module controllers extend these base controllers. The module controller might not exists if I dont want to customize the base controller when using that particular module.
I want to write a logic where laravel route checks if the module controller exists and if it does not it should route to action(basecontroller)..
tried to make middleware and other solutions but cant seem to get this done.
I want to have the routing inside all the controllers done with the same name (thus ignoring the module name - which will be defined by an env variable). so to simplify code I want to call Route::get('apple','AppleController@view') and from this route it should check if App\Http\Controller\module1\module1_AppleController.php exists and if it does use that but incase NotFoundHttpException or other it should route to the base controller action i.e. App\Http\Controller\AppleController..
Cant seem to figure out where to do this with efficient code. can the rewrite be done in RouteServiceProvider in middlaware or other?
also if newer version of laravel present a solution not found in 5.1 i could upgrade, so dont limit answers to 5.1
thanks
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gGay68
via IFTTT
Aucun commentaire:
Enregistrer un commentaire