...
|
...
|
@@ -22,7 +22,7 @@ class LiveController extends BaseController |
|
|
*/
|
|
|
public function actionRoom()
|
|
|
{
|
|
|
|
|
|
|
|
|
$filter = Filter::self()->livingStatus()->keyword()->submit()->reset();
|
|
|
if ($condition = $filter->get_where(true)){
|
|
|
$model = \app\models\Room::condition($condition);
|
...
|
...
|
@@ -30,30 +30,30 @@ class LiveController extends BaseController |
|
|
$model = \app\models\Room::find();
|
|
|
}
|
|
|
//var_dump($condition);
|
|
|
|
|
|
|
|
|
$count = clone $model;
|
|
|
$pagination = new Pagination(['totalCount' =>$count->count()]);
|
|
|
$list = $model
|
|
|
->with('master')
|
|
|
->with(['master','roomNums'])
|
|
|
->offset($pagination->offset)->limit($pagination->limit)
|
|
|
->orderBy(['create_time'=>SORT_DESC,'update_time'=>SORT_DESC])
|
|
|
->all();
|
|
|
//var_dump($list);
|
|
|
|
|
|
|
|
|
foreach ($list as $model){
|
|
|
$app = array_map(function($val){
|
|
|
return ArrayHelper::getValue(Yii::$app->params['config']['app'], $val);
|
|
|
},explode(',',$model->app));
|
|
|
$model->app = implode('<br />', array_filter($app));
|
|
|
}
|
|
|
|
|
|
|
|
|
return $this->render('room',[
|
|
|
'filter'=>$filter,
|
|
|
'pagination'=>$pagination,
|
|
|
'list'=>$list,
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 主播
|
|
|
* @return type
|
...
|
...
|
@@ -81,7 +81,7 @@ class LiveController extends BaseController |
|
|
'list'=>$masters,
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 视频
|
|
|
* @return type
|
...
|
...
|
@@ -99,7 +99,7 @@ class LiveController extends BaseController |
|
|
if(!empty($video->master_id)) {
|
|
|
$liveMasterIds[] = $video->master_id;
|
|
|
}
|
|
|
|
|
|
|
|
|
$app = array_map(function($val){
|
|
|
return ArrayHelper::getValue(Yii::$app->params['config']['app'], $val);
|
|
|
},explode(',',$video->app));
|
...
|
...
|
@@ -113,7 +113,7 @@ class LiveController extends BaseController |
|
|
|
|
|
/**
|
|
|
* 视频编辑
|
|
|
*
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public function actionVideoedit()
|
...
|
...
|
@@ -131,13 +131,13 @@ class LiveController extends BaseController |
|
|
Yii::$app->session->setFlash('success', '编辑成功。');
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
else
|
|
|
{
|
|
|
Yii::$app->session->setFlash('error', '保存失败。');
|
|
|
}
|
|
|
return $this->refresh();
|
|
|
}
|
|
|
else
|
|
|
else
|
|
|
{
|
|
|
$id = Yii::$app->request->get('id', 0);
|
|
|
$video = Video::findOne(['id'=> $id]);
|
...
|
...
|
@@ -151,10 +151,10 @@ class LiveController extends BaseController |
|
|
return $this->render('videoedit', ['video' => $video, 'uploader' => $uploader]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 视频状态设置
|
|
|
* @return
|
|
|
* @return
|
|
|
*/
|
|
|
public function actionVideosetstate()
|
|
|
{
|
...
|
...
|
@@ -174,7 +174,7 @@ class LiveController extends BaseController |
|
|
$this->renderJson(403,'post方式');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 添加主播
|
|
|
* @return type
|
...
|
...
|
@@ -204,10 +204,10 @@ class LiveController extends BaseController |
|
|
}
|
|
|
return $this->redirect('/live/master');
|
|
|
}
|
|
|
|
|
|
|
|
|
//图片上传组件
|
|
|
$uploader = \backend\widgets\UploadImage::self()->logo('pic');
|
|
|
|
|
|
|
|
|
return $this->render('add_master',[
|
|
|
'row'=> $model,
|
|
|
'uploader'=>$uploader,
|
...
|
...
|
@@ -259,32 +259,32 @@ class LiveController extends BaseController |
|
|
* @return type
|
|
|
*/
|
|
|
public function actionDelmaster(){
|
|
|
|
|
|
|
|
|
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
|
|
|
*/
|
|
|
public function actionRoomcreate()
|
|
|
{
|
|
|
{
|
|
|
$model = new \app\models\Room;
|
|
|
if (Yii::$app->getRequest()->isPost){
|
|
|
$post = Yii::$app->getRequest()->post();
|
...
|
...
|
@@ -296,15 +296,15 @@ class LiveController extends BaseController |
|
|
$model->setAttributes($post);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//所有主播
|
|
|
$masters = \app\models\Master::getId2name();
|
|
|
$masters = [''=>'0 无主播']+$masters;
|
|
|
|
|
|
|
|
|
//图片上传组件
|
|
|
$picUploader = \backend\widgets\UploadImage::self()->single('pic');
|
|
|
$backgroundUploader = \backend\widgets\UploadImage::self()->single('background_pic');
|
|
|
|
|
|
|
|
|
return $this->render('roomedit',[
|
|
|
'model'=> $model,
|
|
|
'picUploader'=>$picUploader,
|
...
|
...
|
@@ -312,7 +312,7 @@ class LiveController extends BaseController |
|
|
'masters'=>$masters,
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 编辑直播间
|
|
|
* @return type
|
...
|
...
|
@@ -322,13 +322,13 @@ class LiveController extends BaseController |
|
|
if (!$id = Yii::$app->getRequest()->getQueryParam('id')){
|
|
|
return $this->redirect($this->_refer);
|
|
|
}
|
|
|
|
|
|
|
|
|
$model = new \app\models\Room;
|
|
|
if (!$model = $model->findOne($id)){
|
|
|
Yii::$app->session->setFlash('error', '找不到该直播间');
|
|
|
return $this->redirect($this->_refer);
|
|
|
}
|
|
|
|
|
|
|
|
|
if (Yii::$app->getRequest()->isPost){
|
|
|
$post = Yii::$app->getRequest()->post();
|
|
|
if ($model->edit($post)){
|
...
|
...
|
@@ -338,17 +338,17 @@ class LiveController extends BaseController |
|
|
Yii::$app->session->setFlash('error', '编辑失败。');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
$model->app = explode(',',$model->app);
|
|
|
|
|
|
|
|
|
//所有主播
|
|
|
$masters = \app\models\Master::getId2name();
|
|
|
$masters = [''=>'0 无主播']+$masters;
|
|
|
|
|
|
|
|
|
//图片上传组件
|
|
|
$picUploader = \backend\widgets\UploadImage::self()->single('pic',$model->pic);
|
|
|
$backgroundUploader = \backend\widgets\UploadImage::self()->single('background_pic',$model->background_pic);
|
|
|
|
|
|
|
|
|
return $this->render('roomedit',[
|
|
|
'model'=> $model,
|
|
|
'picUploader'=>$picUploader,
|
...
|
...
|
@@ -356,7 +356,7 @@ class LiveController extends BaseController |
|
|
'masters'=>$masters,
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 直播间操作
|
|
|
* @return type
|
...
|
...
|
@@ -369,12 +369,12 @@ class LiveController extends BaseController |
|
|
if (!$type = Yii::$app->getRequest()->getQueryParam('type')){
|
|
|
return $this->redirect($this->_refer);
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!$model = Room::findOne($id)){
|
|
|
Yii::$app->session->setFlash('error', '找不到该直播间');
|
|
|
return $this->redirect($this->_refer);
|
|
|
}
|
|
|
|
|
|
|
|
|
switch ($type){
|
|
|
case 'del'://删除直播间
|
|
|
$r = $model->del();
|
...
|
...
|
@@ -393,7 +393,7 @@ class LiveController extends BaseController |
|
|
}else{
|
|
|
Yii::$app->session->setFlash('error', '操作失败');
|
|
|
}
|
|
|
|
|
|
|
|
|
return $this->redirect($this->_refer);
|
|
|
}
|
|
|
} |
...
|
...
|
|