<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Banner;
use App\Models\Category;
use App\Models\Course;
use Illuminate\Http\Request;

class HomeController extends Controller
{
    public function index()
    {

        $data = [];

        $data['banners'] = Banner::orderBy('order', 'ASC')->get();
        $data['categories'] = Category::orderBy('display_order', 'ASC')->limit(8)->get();
        $data['courses'] = Course::with('category:id,name')
            ->withAvg('reviews', 'rating')
            ->where('popular', true)
            ->limit(4)
            ->get();

        return sendCustomResponse(true, $data, '', '', 200);
    }
}
