...
|
...
|
@@ -46,26 +46,26 @@ class LiveController extends BaseController |
|
|
*/
|
|
|
public function actionMaster()
|
|
|
{
|
|
|
$query = Master::find();
|
|
|
$conditions = Yii::$app->request->get();
|
|
|
|
|
|
if(array_filter($conditions)){
|
|
|
$sql ="name like '%".$conditions['name']."%'";
|
|
|
$filter = Filter::self()->masterName()->submit()->reset();
|
|
|
if ($condition = $filter->get_where(true)){
|
|
|
$model = Master::condition($condition);
|
|
|
}else{
|
|
|
$sql = "";
|
|
|
$model = Master::find();
|
|
|
}
|
|
|
|
|
|
$count = clone $model;
|
|
|
$pagination = new Pagination([
|
|
|
'defaultPageSize' => 15,
|
|
|
'totalCount' => $query->count(),
|
|
|
'totalCount' => $count->count(),
|
|
|
]);
|
|
|
$masters = $query->where($sql)
|
|
|
->orderBy('create_time')
|
|
|
$masters = $model
|
|
|
->orderBy(['create_time'=>SORT_DESC])
|
|
|
->offset($pagination->offset)
|
|
|
->limit($pagination->limit)
|
|
|
->all();
|
|
|
return $this->render('master',[
|
|
|
'filter'=>$filter,
|
|
|
'pagination'=>$pagination,
|
|
|
'list'=>$masters,
|
|
|
'condition'=>$conditions
|
|
|
]);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -96,53 +96,81 @@ class LiveController extends BaseController |
|
|
}else{
|
|
|
Yii::$app->session->setFlash('error', '保存失败。');
|
|
|
}
|
|
|
return $this->redirect(['master']);
|
|
|
} else {
|
|
|
return $this->render('add_master',['action'=>'/live/addmaster']);
|
|
|
return $this->redirect('live/master');
|
|
|
}
|
|
|
|
|
|
//图片上传组件
|
|
|
$uploader = \backend\widgets\UploadImage::self()->logo('pic');
|
|
|
|
|
|
return $this->render('add_master',[
|
|
|
'row'=> $model,
|
|
|
'uploader'=>$uploader,
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑主播
|
|
|
* @return type
|
|
|
*/
|
|
|
public function actionEditmaster()
|
|
|
{
|
|
|
|
|
|
$id = Yii::$app->request->get('id',0);
|
|
|
$master_id = Yii::$app->request->post('master_id',0);
|
|
|
|
|
|
if($id || $master_id){
|
|
|
if($posts = Yii::$app->request->post()){
|
|
|
$model = Master::findOne($posts['master_id']);
|
|
|
$model->name = $posts['name'];
|
|
|
$model->meta = $posts['meta'];
|
|
|
$model->pic = $posts['pic'];
|
|
|
if($model->save()){
|
|
|
//return $this->redirect(['editmaster','id' => $model->master_id]);
|
|
|
Yii::$app->session->setFlash('success', '编辑成功。');
|
|
|
}else{
|
|
|
Yii::$app->session->setFlash('error', '编辑失败。');
|
|
|
}
|
|
|
return $this->refresh();
|
|
|
if (!$id = Yii::$app->getRequest()->getQueryParam('id')){
|
|
|
return $this->redirect($this->_refer);
|
|
|
}
|
|
|
|
|
|
$model = new Master;
|
|
|
if (!$model = $model->findOne($id)){
|
|
|
Yii::$app->session->setFlash('error', '找不到该主播');
|
|
|
return $this->redirect($this->_refer);
|
|
|
}
|
|
|
|
|
|
if($posts = Yii::$app->request->post()){
|
|
|
$model->name = $posts['name'];
|
|
|
$model->meta = $posts['meta'];
|
|
|
$model->pic = $posts['pic'];
|
|
|
|
|
|
if($model->save()){
|
|
|
Yii::$app->session->setFlash('success', '编辑成功。');
|
|
|
}else{
|
|
|
$row = Master::find()->where(['master_id'=>$id])->one();
|
|
|
return $this->render('add_master',[
|
|
|
'action'=>'/live/editmaster',
|
|
|
'opt'=>'update',
|
|
|
'row'=>$row
|
|
|
]);
|
|
|
Yii::$app->session->setFlash('error', '编辑失败。');
|
|
|
}
|
|
|
return $this->refresh();
|
|
|
}
|
|
|
|
|
|
//图片上传组件
|
|
|
$uploader = \backend\widgets\UploadImage::self()->logo('pic',$model->pic);
|
|
|
|
|
|
return $this->render('add_master',[
|
|
|
'row'=>$model,
|
|
|
'uploader'=>$uploader,
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除主播
|
|
|
* @return type
|
|
|
*/
|
|
|
public function actionDelmaster(){
|
|
|
$id = Yii::$app->request->get('id',0);
|
|
|
if($id){
|
|
|
$model = Master::findOne($id);
|
|
|
if($model->delete()){
|
|
|
return $this->redirect(['master']);
|
|
|
}else{
|
|
|
Yii::$app->session->setFlash('error', '删除失败。');
|
|
|
}
|
|
|
|
|
|
if (!$id = Yii::$app->getRequest()->getQueryParam('id')){
|
|
|
return $this->redirect($this->_refer);
|
|
|
}
|
|
|
|
|
|
$model = new Master;
|
|
|
if (!$model = $model->findOne($id)){
|
|
|
Yii::$app->session->setFlash('error', '找不到该主播');
|
|
|
return $this->redirect($this->_refer);
|
|
|
}
|
|
|
|
|
|
if($model->delete()){
|
|
|
Yii::$app->session->setFlash('success', '删除成功');
|
|
|
}else{
|
|
|
Yii::$app->session->setFlash('error', '删除失败。');
|
|
|
}
|
|
|
|
|
|
return $this->redirect($this->_refer);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 创建直播间
|
|
|
* @return type
|
...
|
...
|
|