| 9 | use Illuminate\Support\Facades\Validator; |
| 10 | |
| 11 | class BaseController extends Controller |
| 12 | { |
| 13 | const PAGE_SIZE = 10; |
| 14 | const PAGE_NO = 1; |
| 15 | |
| 16 | /** |
| 17 | * 操作成功 |
| 18 | * |
| 19 | * @param array $data |
| 20 | * @param string $msg |
| 21 | */ |
| 22 | protected function success($data = [], $msg = '成功') |
| 23 | { |
| 24 | $result = [ |
| 25 | 'code' => 1, |
| 26 | 'data' => $data, |
| 27 | 'msg' => $msg, |
| 28 | ]; |
| 29 | return response()->json($result)->setEncodingOptions(JSON_UNESCAPED_UNICODE); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * 操作失败 |
| 34 | * |
| 35 | * @param array $data |
| 36 | * @param string $msg |
| 37 | */ |
| 38 | protected function fail($msg = '成功', $code = 0, $data = []) |
| 39 | { |
| 40 | $result = [ |
| 41 | 'code' => $code, |
| 42 | 'data' => $data, |
| 43 | 'msg' => $msg, |
| 44 | ]; |
| 45 | return response()->json($result)->setEncodingOptions(JSON_UNESCAPED_UNICODE); |
| 46 | } |
| 47 | } |
nothing calls this directly
no outgoing calls
no test coverage detected