...
|
...
|
@@ -2,9 +2,11 @@ |
|
|
namespace backend\controllers;
|
|
|
|
|
|
use Yii;
|
|
|
use app\models\Master;
|
|
|
use yii\data\Pagination;
|
|
|
|
|
|
/**
|
|
|
* Site controller
|
|
|
* Live controller
|
|
|
*/
|
|
|
class LiveController extends BaseController
|
|
|
{
|
...
|
...
|
@@ -24,7 +26,27 @@ class LiveController extends BaseController |
|
|
*/
|
|
|
public function actionMaster()
|
|
|
{
|
|
|
return $this->render('master');
|
|
|
$query = Master::find();
|
|
|
$conditions = Yii::$app->request->get();
|
|
|
|
|
|
if(array_filter($conditions)){
|
|
|
$sql ="name like '%".$conditions['name']."%'";
|
|
|
}else{
|
|
|
$sql = "";
|
|
|
}
|
|
|
$pagination = new Pagination([
|
|
|
'defaultPageSize' => 15,
|
|
|
'totalCount' => $query->count(),
|
|
|
]);
|
|
|
$masters = $query->where($sql)
|
|
|
->orderBy('create_time')
|
|
|
->offset($pagination->offset)
|
|
|
->limit($pagination->limit)
|
|
|
->all();
|
|
|
return $this->render('master',[
|
|
|
'list'=>$masters,
|
|
|
'condition'=>$conditions
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -35,4 +57,67 @@ class LiveController extends BaseController |
|
|
{
|
|
|
return $this->render('video');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加主播
|
|
|
* @return type
|
|
|
*/
|
|
|
public function actionAddmaster()
|
|
|
{
|
|
|
$model = new Master();
|
|
|
|
|
|
if ($posts = Yii::$app->request->post()) {
|
|
|
$model->name = $posts['name'];
|
|
|
$model->meta = $posts['meta'];
|
|
|
$model->pic = $posts['pic'];
|
|
|
$model->create_time = $model->update_time = time();
|
|
|
if($model->save()){
|
|
|
return $this->redirect(['master']);
|
|
|
}else{
|
|
|
die("保存失败");
|
|
|
}
|
|
|
} else {
|
|
|
return $this->render('add_master',['action'=>'/live/addmaster']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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]);
|
|
|
}else{
|
|
|
die("保存失败");
|
|
|
}
|
|
|
}else{
|
|
|
$row = Master::find()->where(['master_id'=>$id])->one();
|
|
|
return $this->render('add_master',[
|
|
|
'action'=>'/live/editmaster',
|
|
|
'opt'=>'update',
|
|
|
'row'=>$row
|
|
|
]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public function actionDelmaster(){
|
|
|
$id = Yii::$app->request->get('id',0);
|
|
|
if($id){
|
|
|
$model = Master::findOne($id);
|
|
|
if($model->delete()){
|
|
|
return $this->redirect(['master']);
|
|
|
}else{
|
|
|
echo "删除失败";exit;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|