HomeController.php 1.1 KB

123456789101112131415161718192021222324252627282930
  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\Enums\School\LessonScheduleStatusEnum;
  13. use App\Repositories\Enums\School\ScheduleTypeEnum;
  14. use App\Repositories\Models\School\LessonSchedule;
  15. use Illuminate\Http\Request;
  16. use Jiannei\Response\Laravel\Support\Facades\Response;
  17. class HomeController extends Controller
  18. {
  19. public function index(Request $request)
  20. {
  21. $lesson_total_nums = LessonSchedule::query()->where('term_id', self::$TERM_ID)->where('type', ScheduleTypeEnum::LESSON)->where('status', LessonScheduleStatusEnum::OK)->count();
  22. $lesson_use_nums = LessonSchedule::query()->where('term_id', self::$TERM_ID)->whereDate('day', '<', date('Y-m-d'))->where('type', ScheduleTypeEnum::LESSON)->where('status', LessonScheduleStatusEnum::OK)->count();
  23. return Response::success(compact('lesson_total_nums', 'lesson_use_nums'));
  24. }
  25. }