New to laravel and trying to develop a better way to structure my application.
It has both an admin interface and an API (JSON, front-end corner).
Now my routes are as follows:
Route::group(array('prefix' => 'admin', 'before' => 'auth.admin'), function()
{
Route::any('/', array('as' => 'admin.index', function() {
return View::make('admin.index');
}));
Route::resource('countries.products', 'ProductsController');
Route::resource('countries', 'CountriesController');
Route::resource('orders', 'OrdersController');
});
Route::group(array('prefix' => 'api/v1'), function()
{
Route::resource('products', 'APIProductsController', array('only' => array('index', 'show')));
Route::resource('orders', 'APIOrdersController', array('only' => array('store', 'update')));
});
There is a lot of duplicate logic, for example, OrdersController and APIOrdersController. Should I ever use one controller, possibly with content? or is it better to modify the OrdersController to request API routes instead of using the eloquent one?
or is there another, better way?
source
share