1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace app\admin\model;
- use support\Db;
- use support\Model;
- /**
- * 书院订单模型
- * Class Users
- * @package app\admin\model
- */
- class BookCourse extends Model
- {
- /**
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'life_book_course_order';
- public $timestamps = false;
- /**
- * Notes:书院订单列表
- * @param string $keywords
- * @param int $page
- * @param int $limit
- * @return array
- * User: ZQ-QJF
- * Date: 2022/10/14
- */
- public static function getOrderList(int $page, int $limit, string $keywords)
- {
- $list = static::select('*')
- ->where(['order_is_del'=>0])
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('order_dno', $keywords);
- })
- ->with(['User'])
- ->orderBy('order_create_time','DESC')
- ->forPage($page, $limit)
- ->get();
- $count = static::where(['order_is_del'=>0])
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('order_dno', $keywords);
- })
- ->count();
- return [$list, $count];
- }
- public function User(){
- return $this->belongsTo(User::class,'order_user_id','user_id');
- }
- public function getOrderPayTimeAttribute($value)
- {
- return date('Y-m-d H:i:s', $value);
- }
- public function Detail(){
- return $this->hasMany(BookCourseLog::class,'log_order_id','order_id');
- }
- }
|