* * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use App\Repositories\Models\Course\Course; use App\Repositories\Models\Course\Video; use App\Repositories\Models\Inform\Category; use App\Repositories\Models\Inform\Information; use App\Repositories\Models\UserVideoWatchRecord; use Carbon\Carbon; use Jiannei\Response\Laravel\Support\Facades\Response; class HomeController extends Controller { public function index() { $now = Carbon::now()->toDateTimeString(); $hot_courses = Course::query()->where('published_at', '<=', $now)->with(['thumb_resource'])->orderByDesc('user_count')->limit(4)->get(); $rec_courses = Course::query()->where('published_at', '<=', $now)->with(['thumb_resource'])->orderByDesc('is_rec')->orderByDesc('user_count')->limit(4)->get(); return Response::success(compact('hot_courses', 'rec_courses')); } }