HomeController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /*
  3. * This file is part of the Jiannei/lumen-api-starter.
  4. *
  5. * (c) Jiannei <longjian.huang@foxmail.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace App\Http\Controllers\Admin;
  11. use App\Http\Controllers\Controller;
  12. use App\Repositories\Eloquent\Inform\InformationRepositoryEloquent;
  13. use App\Repositories\Models\Course\Course;
  14. use App\Repositories\Models\Exam\Paper;
  15. use App\Repositories\Models\Exam\Topic;
  16. use App\Repositories\Models\Inform\Information;
  17. use App\Repositories\Models\User\User;
  18. use App\Repositories\Models\UserVideoWatchRecord;
  19. use Carbon\Carbon;
  20. use Jiannei\Response\Laravel\Support\Facades\Response;
  21. class HomeController extends Controller
  22. {
  23. public function index(InformationRepositoryEloquent $informationRepositoryEloquent)
  24. {
  25. // $notices = Information::query()->status()->where('organization_id', 0)->where('category_id', 1)->orderBy('sort')->orderByDesc('id')->limit(3)->get();
  26. // $notices = $informationRepositoryEloquent->parserResult($notices)['list'];
  27. //
  28. // $teacher_nums = User::query()->where('role_id', 1)->status()->count();
  29. // $student_nums = User::query()->where('role_id', 0)->status()->count();
  30. // $course_nums = Course::query()->status()->count();
  31. // $paper_nums = Paper::query()->status()->count();
  32. // $topic_nums = Topic::query()->status()->count();
  33. //
  34. //
  35. // $study_statistical = [];
  36. //
  37. // for ($i = 30; $i > 0; $i--) {
  38. // $day = Carbon::now()->addDays(-$i)->toDateString();
  39. // $watch_user_nums = UserVideoWatchRecord::query()->whereDate('watched_at', $day)->distinct()->pluck('user_id');
  40. // $study_statistical[] = [
  41. // 'day' => $day,
  42. // 'watch_user_nums' => count($watch_user_nums),
  43. // 'user_nums' => User::query()->whereDate('created_at', $day)->where('role_id', 0)->count(),
  44. // ];
  45. // }
  46. // return Response::success(compact('notices', 'teacher_nums', 'student_nums', 'course_nums', 'paper_nums', 'topic_nums', 'study_statistical'));
  47. return Response::success('mead');
  48. }
  49. }