作者 xwp
1 个管道 的构建 通过 耗费 5 秒

评价管理逻辑完成

... ... @@ -86,6 +86,27 @@ class CourseSignStart extends Backend
}
return $this->view->fetch();
}
/**
* 切换
* @param $ids
* @return mixed
*/
public function change($ids = '')
{
//你需要在此做具体的操作逻辑
$data = $this->model->where(['id'=>$ids])->find();
if(empty($data)){
$this->error("没有这个评价",$ids);
}
$data = $data->toArray();
($data['status'] == 'true')?$status = 'false':$status = 'true';
$data = $this->model->where(['id'=>$ids])->update(['status'=>$status]);
$this->success("切换成功");
}
}
... ...
... ... @@ -66,4 +66,25 @@ class CourseSignStartSet extends Backend
return $this->view->fetch();
}
/**
* 切换
* @param $ids
* @return mixed
*/
public function change($ids = '')
{
//你需要在此做具体的操作逻辑
$data = $this->model->where(['id'=>$ids])->find();
if(empty($data)){
$this->error("没有这个评价",$ids);
}
$data = $data->toArray();
($data['status'] == 'true')?$status = 'false':$status = 'true';
$data = $this->model->where(['id'=>$ids])->update(['status'=>$status]);
$this->success("切换成功");
}
}
... ...
... ... @@ -305,7 +305,7 @@ class Course extends Api
//查询评价
$star = new \app\admin\model\CourseSignStart();
$star1 = $star->with('user')->where(['course_id'=>$id])->order('create_time','desc')->select();
$star1 = $star->with('user')->where(['course_id'=>$id,'status'=>'true'])->order('create_time','desc')->select();
foreach ($star1 as &$k){
$banner = explode(",", $k['pic']);
foreach ($banner as &$v){
... ... @@ -318,7 +318,7 @@ class Course extends Api
unset($k);
//查询评价
$star = new \app\admin\model\CourseSignStartSet();
$star2 = $star->where(['course_id'=>$id])->order('create_time','desc')->select();
$star2 = $star->where(['course_id'=>$id,'status'=>'true'])->order('create_time','desc')->select();
foreach ($star2 as &$kk){
$banner = explode(",", $kk['pic']);
foreach ($banner as &$vv){
... ... @@ -435,6 +435,7 @@ class Course extends Api
'store_id' => $sign['store_id'],
'course_id' => $sign['course_id'],
'create_time' => date('Y-m-d H:i:s'),
'status' => 'false',
];
$Star = new \app\admin\model\CourseSignStart();
... ...
... ... @@ -87,6 +87,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}
return html;
},events: Table.api.events.image},
{field: 'status', title: __('是否显示'),formatter: function (value, row, index) {
return '<a class="btn-change text-success" data-url="course_sign_start/change" data-id="' + row.id + '"><i class="fa ' + (row.status === 'true' ?'fa-toggle-on fa-flip-horizontal' : 'fa-toggle-off fa-flip-horizontal text-gray' ) + ' fa-2x"></i></a>';
}
},
//{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...
... ... @@ -50,6 +50,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'course.name', title: __('Course_id')},
{field: 'store.name', title: __('Store_id')},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange'},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange'},
{field: 'status', title: __('是否显示'),formatter: function (value, row, index) {
return '<a class="btn-change text-success" data-url="course_sign_start_set/change" data-id="' + row.id + '"><i class="fa ' + (row.status === 'true' ?'fa-toggle-on fa-flip-horizontal' : 'fa-toggle-off fa-flip-horizontal text-gray' ) + ' fa-2x"></i></a>';
}
},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...