Last active
August 27, 2016 10:32
-
-
Save jadjoubran/0905e223e37657427d4b8c6573ab0ee0 to your computer and use it in GitHub Desktop.
Laravel Response Macro - Original PostsController.php
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 | |
use App\Post; | |
class PostsController | |
{ | |
public function get() | |
{ | |
try { | |
//some code | |
}catch (Exception $e){ | |
//error | |
return [ | |
'errors' => true, | |
'message' => $e->getMessage() | |
]; | |
} | |
$posts = Post::get(); | |
//success | |
return [ | |
'errors' => false, | |
'data' => compact('posts') | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment