Commit 69e4b998 authored by wangzhengwen's avatar wangzhengwen

分类修改

parent 775bfd0e
......@@ -157,9 +157,22 @@ class Course extends BaseController
$data = $request->param();
$data = (new CourseModel())
->with(['getSections'=>['getCourseClass'=>['fileData']],'getCourseClass'=>['fileData']])
->where('id',$data['course_id'])
->field('id,thumb,title,createtime,description,price,content,teacher_id,tvclick,click')
->with([
'getSections' => function ($query) {
$query->with(['getCourseClass' => function ($query) {
$query->with(['fileData'])
->append(['tvtime_str'])
->order('sort', 'asc'); // 按 sort 升序排序
}]);
},
'getCourseClass' => function ($query) {
$query->with(['fileData'])
->append(['tvtime_str'])
->order('sort', 'asc'); // 按 sort 升序排序
}
])
->where('id', $data['course_id'])
->field('id, thumb, title, createtime, description, price, content, teacher_id, tvclick, click')
->find();
return $this->returnMsg('success',1,$data);
......
......@@ -83,6 +83,8 @@ class User extends BaseController
$user['reg_time'] = time();
$user['create_time'] = time();
$user['role'] = $data['role'] ?? 1;
$user['headico'] = vconfig('default_user') ?? null;
$res = userModel::insert($user);
if (!$res)
{
......
......@@ -71,11 +71,14 @@ class Cert extends Model
public function getCertList($category_id,$page,$pageSize,$type,$searchKeyWords=null)
{
$where = ['is_sell' => 1, 'is_del' => 0];
$query = self::where($where);
if ($category_id) {
$where['cate_id'] = $category_id;
// $where['cate_id'] = $category_id;
$son_ids = CertCategory::where('pid', $category_id)->column('id');
$query->whereIn('cate_id', array_merge([$category_id], $son_ids));
}
$query = self::where($where);
if ($searchKeyWords)
{
......
......@@ -13,4 +13,23 @@ class CourseClass extends Model
->where('isdel',0)
->field('fileid,filename,filesize,fileurl,filetype,storage');
}
public function getTvtimeStrAttr($value,$data)
{
if (empty($data['tvtime'])) {
return null;
}
$hours = floor($data['tvtime'] / 3600);
$minutes = floor(($data['tvtime'] % 3600) / 60);
$seconds = $data['tvtime'] % 60;
// 如果小时为0,则只返回 i:s 格式
if ($hours == 0) {
return sprintf("%02d:%02d", $minutes, $seconds);
}
// 否则返回 H:i:s 格式
return sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds);
}
}
\ No newline at end of file
......@@ -115,12 +115,14 @@ class Project extends Model
{
$where = ['sh_status' => 2, 'status' => 1];
$query = self::where($where);
if ($category_id) {
$where['cate_id'] = $category_id;
// $where['cate_id'] = $category_id;
$son_ids = ProjectCategory::where('pid', $category_id)->column('id');
$query->whereIn('cate_id', array_merge([$category_id], $son_ids));
}
$query = self::where($where);
if ($searchKeyWords)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment