laravel call传参

public function index(Request $request, ApplicationContract $app)
    {
        $type = $request->query('type', 'all');
        $user_id = $request->has('user_id') ? (int) $request->query('user_id') : $request->user('api')->id ?? 0;

        if (! in_array($type, ['all', 'adoption', 'invitation', 'other'])) {
            $type = 'all';
        }

        return response()->json($app->call([$this, $type], ['user_id' => $user_id]), 200);
    }
posted @ 2019-04-15 14:20  心之所依  阅读(780)  评论(0编辑  收藏  举报