123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- /*
- * This file is part of the Jiannei/lumen-api-starter.
- *
- * (c) Jiannei <longjian.huang@foxmail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- namespace App\Http\Controllers\Admin;
- use App\Http\Controllers\Controller;
- use App\Repositories\Eloquent\Inform\InformationRepositoryEloquent;
- use App\Repositories\Models\Course\Course;
- use App\Repositories\Models\Exam\Paper;
- use App\Repositories\Models\Exam\Topic;
- use App\Repositories\Models\Inform\Information;
- use App\Repositories\Models\User\User;
- use App\Repositories\Models\UserVideoWatchRecord;
- use Carbon\Carbon;
- use Jiannei\Response\Laravel\Support\Facades\Response;
- class HomeController extends Controller
- {
- public function index(InformationRepositoryEloquent $informationRepositoryEloquent)
- {
- // $notices = Information::query()->status()->where('organization_id', 0)->where('category_id', 1)->orderBy('sort')->orderByDesc('id')->limit(3)->get();
- // $notices = $informationRepositoryEloquent->parserResult($notices)['list'];
- //
- // $teacher_nums = User::query()->where('role_id', 1)->status()->count();
- // $student_nums = User::query()->where('role_id', 0)->status()->count();
- // $course_nums = Course::query()->status()->count();
- // $paper_nums = Paper::query()->status()->count();
- // $topic_nums = Topic::query()->status()->count();
- //
- //
- // $study_statistical = [];
- //
- // for ($i = 30; $i > 0; $i--) {
- // $day = Carbon::now()->addDays(-$i)->toDateString();
- // $watch_user_nums = UserVideoWatchRecord::query()->whereDate('watched_at', $day)->distinct()->pluck('user_id');
- // $study_statistical[] = [
- // 'day' => $day,
- // 'watch_user_nums' => count($watch_user_nums),
- // 'user_nums' => User::query()->whereDate('created_at', $day)->where('role_id', 0)->count(),
- // ];
- // }
- // return Response::success(compact('notices', 'teacher_nums', 'student_nums', 'course_nums', 'paper_nums', 'topic_nums', 'study_statistical'));
- return Response::success('mead');
- }
- }
|