| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 | <?phpnamespace app\admin\model;use support\Db;use support\Model;/** * 万悦书院课程排期模型 * Class Users * @package app\admin\model */class LifeBookScheduling extends Model{    const IS_DEL_YES = 1;    const IS_DEL_NO  = 0;    const SCHEDULING_IS_SHOW = [        self::IS_DEL_YES => '已删除',        self::IS_DEL_NO  => '未删除'    ];    /**     * The table associated with the model.     *     * @var string     */    protected $table = 'life_book_scheduling';    public $timestamps = false;    /**     * Notes:获取课程排期列表     * @param string $keywords     * @param int $page     * @param int $limit     * @return array     * User: ZQ     * Date: 2022/10/14     */    public static function getBookSchedulingList(int $page, int $limit, string $keywords)    {        $list = static::select(['life_book_scheduling.*','life_book.life_book_name','category.category_name'])            ->where(['scheduling_is_del'=>static::IS_DEL_NO])            ->when($keywords != '', function ($query) use ($keywords){                $query->where('scheduling_book_id', 'like', '%' . $keywords . '%');            })            ->leftJoin('life_book','life_book_id','=','life_book_scheduling.scheduling_book_id')            ->leftJoin('category','category_id','=','life_book_scheduling.scheduling_category_id')            ->orderBy('scheduling_create_time','DESC')            ->forPage($page, $limit)            ->get();        $count = static::where(['scheduling_is_del'=>static::IS_DEL_NO])            ->when($keywords != '', function ($query) use ($keywords){                $query->where('scheduling_name', 'like', '%' . $keywords . '%');            })            ->count();        return [$list, $count];    }    /**     * Notes:获取所有课程     * @return array     * User: ZQ     * Date: 2022/10/14     */    public static function getBookAll()    {        $list = static::select(['scheduling_id','scheduling_name'])            ->where(['scheduling_is_del'=>static::IS_DEL_NO])            ->orderBy('scheduling_create_time','DESC')            ->get();        return $list;    }    /**     * Notes:获取课程目录名称     * @param string $account     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null     * User: ZQ     * Date: 2022/10/14     */    public static function schedulingMation($admin_cinema)    {        $where = [];        $where['scheduling_is_del'] = static::IS_DEL_NO;        $mation = static::where($where)            ->when($admin_cinema != '', function ($query) use ($admin_cinema){                $query->whereIn('scheduling_id', $admin_cinema);            })            ->get('scheduling_name');        return $mation;    }}
 |