<?php

namespace app\api\controller\auti;

use app\models\course\OrganModel;
use app\models\course\CourseModel;
use app\Request;
use crmeb\services\UtilService;

class CourseController
{
    public function organList(Request $request)
    {
        $where = UtilService::getMore([
            [['page', 'd'], 1],
            [['limit', 'd'], 15]
        ], $request);
        $list = OrganModel::systemPage($where);
        return app('json')->successful($list);
    }

    public function organ($id)
    {
        $info = OrganModel::where('is_del', 0)->find($id)->toArray();
        return app('json')->successful($info);
    }

    public function list(Request $request)
    {
        $where = UtilService::getMore([
            [['page', 'd'], 1],
            [['limit', 'd'], 15],
            ['area', '']
        ], $request);
        $list = CourseModel::systemPage($where);
        return app('json')->successful($list);
    }

    public function detail($id)
    {
        $info = CourseModel::where('is_del', 0)->find($id)->toArray();
        return app('json')->successful($info);
    }
}