* * 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\Course; use App\Http\Controllers\Controller; use App\Http\Resources\CMS\BannerResource; use App\Repositories\Enums\Base\BannerTypeEnum; use App\Repositories\Models\Base\Banner; use App\Repositories\Models\Course\Category; use App\Repositories\Models\Info\Information; use App\Repositories\Presenters\Base\BannerPresenter; use App\Repositories\Presenters\Info\InformationPresenter; use Illuminate\Support\Facades\Request; use Jiannei\Response\Laravel\Support\Facades\Response; class HomeController extends Controller { public function index(Request $request) { $category = Category::query()->where('parent_id', 0)->status()->select(['id', 'name'])->orderByDesc('sort')->get(); $banners = Banner::query()->status()->active()->where('type', BannerTypeEnum::HOME)->orderBy('sort')->get(); $banners = (new BannerPresenter())->present($banners); $notice = Information::query()->status()->where('type_id', 1)->orderBy('sort')->orderByDesc('id')->limit(3)->get(); $notice = (new InformationPresenter())->present($notice); $news = Information::query()->status()->where('type_id', 2)->orderBy('sort')->orderByDesc('id')->limit(4)->get(); $news = (new InformationPresenter())->present($news); return Response::success(compact('category', 'banners', 'news', 'notice')); } }