laravel 模型关联查询分页应该怎么写呢?

$user = User::withCount('schools')->with(['schools' => function($query) use ($request){

            if($request->filled('name')) $query->where('name', 'like', '%'. $request->input('name') .'%');

            $query->with('wechat')->paginate(10);
        }])->findOrFail(1);

        $schools = new LengthAwarePaginator(
            $user->schools,
            $user->schools_count,
            10,
            $request->input('page', 1),
            ['path' => $request->url()]
        );
        return new SchoolCollection($schools);

上面是我现在写的,这个代码好难看,不知道应该怎么优雅的符合laravel的风格.望指教

JellyBool
修改的评论也不能少于六个字哦!