MCPcopy Create free account
hub / github.com/CoderOpen/waimai / BaseController

Class BaseController

app/Http/Controllers/Api/BaseController.php:11–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9use Illuminate\Support\Facades\Validator;
10
11class 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected