Created
October 16, 2012 03:02
-
-
Save bayleedev/3897032 to your computer and use it in GitHub Desktop.
Rewrite response in laravel
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 | |
Route::filter('after', function($response) | |
{ | |
$params = \Laravel\Request::$route->parameters; | |
// The 'type' is the last param | |
// example: /product/(:num).(:any) | |
$type = array_pop($params); | |
if($type == 'json') { | |
$res = Response::json($response->content->data); | |
foreach($response as $key => &$value) { | |
$response->$key = $res->$key; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment