Skip to content

Instantly share code, notes, and snippets.

@MrAtiebatie
Last active August 29, 2015 14:15
Show Gist options
  • Save MrAtiebatie/0e31af54e8ad461caa50 to your computer and use it in GitHub Desktop.
Save MrAtiebatie/0e31af54e8ad461caa50 to your computer and use it in GitHub Desktop.
Laravel Nested RESTful Controllers
<?php
/**
* This is an example code for how to use nested RESTful controllers
* in Laravel 4 & 5. Yes, in this case you could you use a resource
* controller but sometimes you don't have the same method names
* as a resource controller. The method names in this example weren't
* my case so it's just some example code.
*
* You can also use static function calls instead of OOP way.
*/
$router->group(array('prefix' => 'users/{id}'), function() use ($router) {
// Images controller
$router->controller('images', 'ImagesController', [
'getIndex' => 'user.images.index',
'getShow' => 'user.images.show'
]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment