-
-
Save timothylhuillier/5666424 to your computer and use it in GitHub Desktop.
API or NOT API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
////////////////////////////////////////////////////////////////////// | |
//////////////////////// METHODOLOGIE SEPARÉE //////////////////////// | |
////////////////////////////////////////////////////////////////////// | |
// app/controllers/UsersController --------------------------------- / | |
class UsersController | |
{ | |
public function getUser($id) | |
{ | |
$user = User::findOrFail($id); | |
return View::make('users.show') | |
->with('user', $user); | |
} | |
} | |
// app/controllers/Api/UsersController ----------------------------- / | |
namespace Api; | |
class UsersController | |
{ | |
public function getUser($id) | |
{ | |
$user = User::findOrFail($id); | |
return $user; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
////////////////////////////////////////////////////////////////////// | |
//////////////////////// METHODOLOGIE UNIFIÉE //////////////////////// | |
////////////////////////////////////////////////////////////////////// | |
// app/controllers/UsersController --------------------------------- / | |
class UsersController | |
{ | |
/** | |
* Instance of the Users API | |
* | |
* @var Api\UsersController | |
*/ | |
protected $api; | |
public function __construct() | |
{ | |
$this->api = new Api\UsersController; | |
} | |
public function getUser($id) | |
{ | |
$user = $this->api->getUser($id); | |
return View::make('users.show') | |
->with('user', $user); | |
} | |
} | |
// app/controllers/Api/UsersController ----------------------------- / | |
namespace Api; | |
class UsersController | |
{ | |
public function getUser($id) | |
{ | |
$user = User::findOrFail($id); | |
return $user; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment