Skip to content

Instantly share code, notes, and snippets.

@jadjoubran
Created August 27, 2016 10:34
Show Gist options
  • Save jadjoubran/e8e19fec70d9e9f58a3a770347fb9ae7 to your computer and use it in GitHub Desktop.
Save jadjoubran/e8e19fec70d9e9f58a3a770347fb9ae7 to your computer and use it in GitHub Desktop.
Laravel Response Macros - Refactored
<?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