Created
August 27, 2016 10:34
-
-
Save jadjoubran/e8e19fec70d9e9f58a3a770347fb9ae7 to your computer and use it in GitHub Desktop.
Laravel Response Macros - Refactored
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 | |
class PostsController | |
{ | |
public function get() | |
{ | |
try { | |
//some code | |
}catch (Exception $e){ | |
return response()->error($e->getMessage); | |
} | |
$posts = Post::get(); | |
return response()->success(compact('posts')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment