Created
November 1, 2017 16:51
-
-
Save afiqiqmal/df68de75c3ff6475c4c2190adf67b760 to your computer and use it in GitHub Desktop.
This is a sample static class for returning json
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 | |
namespace App\Library; | |
class Message | |
{ | |
public static function error($msg = 'Something went wrong', $code = 400, $reference = null) | |
{ | |
return response()->json( | |
[ | |
'error' => true, | |
'message' => $msg, | |
'reference' => $reference, | |
], | |
$code | |
); | |
} | |
public static function success($msg = 'Request Success', $code = 200, $obj = null) | |
{ | |
return response()->json( | |
[ | |
'error' => false, | |
'message' => $msg, | |
'data' => $obj, | |
], | |
$code | |
); | |
} | |
} |
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 | |
return Message::error("Unauthorized user. Please Contact Admin to Active", 401); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment