<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ### 內置`http`常用方法和屬性 ~~~ // 獲取get參數 $params = $this->get; // 獲取post參數 $bodyParams = $this->post; // 是否是post請求 $this->isPost; // 是否是get請求 $this->isGet; // 是否是ajax請求(泛指) $this->isAjax; // 是否是ajax請求(非泛指) $this->getIsAjax(false) // 獲取當前完整域名 $this->domain; // Json成功響應 return $this->asSuccess(''); // Json失敗響應 return $this->asFail(''); // Json未授權響應 return $this->asUnauthorized(''); ~~~ > `get`、`post`內置了數據過濾功能,自動將空字符串轉為`null` ### 內置過濾器 ```php // 方法的請求動作定義 public $actionVerbs = []; // 游客方法定義 public $guestActions = []; // 不進行RBAC檢查的方法定義 public $undetectedActions = []; ``` 例子: ~~~ <?php // +---------------------------------------------------------------------- // | yii-manager version 1.0.0 // +---------------------------------------------------------------------- // | 日期:2020/8/13 // +---------------------------------------------------------------------- // | 作者:cleverstone // +---------------------------------------------------------------------- namespace app\admin\controllers; use app\models\AdminUser; use app\builder\ViewBuilder; use app\builder\table\Table; use app\builder\helper\DateSplitHelper; use app\builder\common\CommonController; use app\builder\table\ToolbarFilterOptions; use app\builder\table\widgets\SelectConnection; /** * 首頁 * @author cleverstone * @since 1.0 */ class IndexController extends CommonController { /** * {@inheritdoc} */ public $actionVerbs = [ 'index' => ['get'], 'add' => ['get', 'post'], 'edit' => ['get', 'post'], 'disable' => ['get', 'post'], ]; /** * {@inheritdoc} */ public $guestActions = [ 'index', 'add', 'edit', 'disable', ]; /** * {@inheritdoc} */ public $undetectedActions = []; /** * Renders the index view for the module * @return string * @throws \yii\base\NotSupportedException * @throws \Throwable * @author cleverstone * @since 1.0 */ public function actionIndex() { $params = $this->get; $tableBuilder = ViewBuilder::table(); $tableBuilder->title = '首頁'; $tableBuilder->widget = [ Table::TABLE_TOOL_TOP => '<p style="padding:10px;padding-bottom:0;">這里是工具欄頭部</p>', Table::TABLE_TOOL_BOTTOM => '<p style="padding:10px;padding-bottom:0;">這里是工具欄底部</p>', Table::TABLE_PAGE_TOP => '<p style="padding:10px;padding-bottom:0;">這里是分頁頭部</p>', Table::TABLE_PAGE_BOTTOM => '<p style="padding:10px;padding-bottom:0;">這里是分頁底部</p>', ]; $tableBuilder->columns = [ 'username' => table_column_helper('用戶名', ['style' => ['min-width' => '100px']]), 'email' => table_column_helper('郵箱', ['style' => ['min-width' => '200px']]), 'an_mobile' => table_column_helper('電話', ['style' => ['min-width' => '100px']], function ($item) { return '+' . $item['an'] . ' ' . $item['mobile']; }), 'status_label' => table_column_helper('狀態', ['style' => ['min-width' => '80px']], function ($item) { switch ($item['status']){ case 0: return '<span class="label label-danger">已封停</span>'; case 1: return '<span class="label label-success">正常</span>'; default: return '<span class="label label-default">未知</span>'; } }), 'identify_code' => table_column_helper('邀請碼', ['style' => ['min-width' => '100px']]), 'created_at' => table_column_helper('注冊時間', ['style' => ['min-width' => '180px']]), 'updated_at' => table_column_helper('更新時間', ['style' => ['min-width' => '180px']]), ]; $tableBuilder->query = function () use ($params) { $start = null; $end = null; if (!empty($params['created_at'])) { list($start, $end) = DateSplitHelper::create($params['created_at'])->reformat()->toArray();; } $query = AdminUser::find() ->filterWhere([ 'and', ['between', 'created_at', $start, $end], ['status' => isset($params['status']) ? $params['status'] : null], [ 'or', ['like', 'username', isset($params['keyword']) ? $params['keyword'] : null], ['like', 'email', isset($params['keyword']) ? $params['keyword'] : null], ] ]) ->select([ 'id', 'username', 'email', 'an', 'mobile', 'status', 'identify_code', 'created_at', 'updated_at', ]); return $query; }; $tableBuilder->orderBy = 'id DESC'; $tableBuilder->primaryKey = 'id'; $tableBuilder->page = true; $tableBuilder->hideCheckbox = false; $tableBuilder->rowActions = [ table_action_helper('ajax', [ 'title' => '解封/封停', 'icon' => 'fa fa-lock', 'route' => 'admin/index/disable', 'params' => ['id', 'status'], 'method' => 'post', ]), //table_action_helper('division', []), table_action_helper('modal', [ 'title' => '編輯', 'icon' => 'fa fa-pencil-square-o', 'route' => 'admin/index/edit', 'width' => '60%', 'height' => '80%', ]), table_action_helper('page', [ 'title' => '新增', 'icon' => 'fa fa-plus', 'route' => 'admin/index/add', ]), ]; $tableBuilder->toolbarRefresh = []; $tableBuilder->toolbarFilter = [ 'title' => '', 'icon' => '', 'columns' => [ 'keyword' => table_toolbar_filter_helper([ 'control' => ToolbarFilterOptions::CONTROL_TEXT, 'label' => '關鍵詞', 'placeholder' => '請填寫關鍵詞', ]), /*'email' => table_toolbar_filter_helper([ 'control' => ToolbarFilterOptions::CONTROL_NUMBER, 'label' => '數字', 'placeholder' => '請填寫數字', ]),*/ 'created_at' => table_toolbar_filter_helper([ 'control' => ToolbarFilterOptions::CONTROL_DATETIME, 'label' => '注冊時間', 'range' => 1, 'placeholder' => '請選擇注冊時間', ]), /*'date' => table_toolbar_filter_helper([ 'control' => ToolbarFilterOptions::CONTROL_DATE, 'label' => '日期', 'range' => 1, 'placeholder' => '請選擇日期', ]), 'year' => table_toolbar_filter_helper([ 'control' => ToolbarFilterOptions::CONTROL_YEAR, 'label' => '年份', 'range' => 1, 'placeholder' => '請選擇年份', ]), 'month' => table_toolbar_filter_helper([ 'control' => ToolbarFilterOptions::CONTROL_MONTH, 'label' => '月份', 'range' => 1, 'placeholder' => '請選擇月份', ]), 'time' => table_toolbar_filter_helper([ 'control' => ToolbarFilterOptions::CONTROL_TIME, 'label' => '時間', 'range' => 1, 'placeholder' => '請選擇時間', ]),*/ 'status' => table_toolbar_filter_helper([ 'control' => ToolbarFilterOptions::CONTROL_SELECT, 'label' => '狀態', 'placeholder' => '請選擇狀態', 'default' => '', 'options' => [ '0' => '封停', '1' => '正常', ], ]), 'custom' => table_toolbar_filter_helper([ 'control' => 'custom', 'widget' => new SelectConnection(), ]), ], ]; $tableBuilder->toolbarExport = [ 'icon' => '', 'name' => '會員列表', 'heads' => ['ID', '用戶名', '郵箱', '電話'], 'fields' => ['id', 'username', 'email', 'an', 'mobile'], 'columns' => [ 'id', 'username', 'email', 'mobile' => function ($item) { return '+' . $item['an'] . ' ' . $item['mobile']; }, ], ]; $tableBuilder->toolbarCustom = [ table_toolbar_custom_helper('left', [ 'title' => '禁用', 'icon' => 'glyphicon glyphicon-remove', 'option' => 'ajax', 'method' => 'POST', 'route' => 'admin/index/disable', 'params' => ['id', 'status'], ]), table_toolbar_custom_helper('left', [ 'title' => '新增', 'icon' => 'glyphicon glyphicon-plus', 'option' => 'modal', 'width' => '60%', 'height' => '80%', 'route' => 'admin/index/edit', ]), table_toolbar_custom_helper('left', [ 'title' => '頁面', 'icon' => 'glyphicon glyphicon-list-alt', 'option' => 'page', 'params' => ['id', 'status'], 'route' => 'admin/index/edit', ]), ]; return $tableBuilder->render($this); } /** * 新增 * @return string * @throws \Throwable * @author cleverstone * @since 1.0 */ public function actionAdd() { $formBuilder = ViewBuilder::form(); $formBuilder->title = '新增'; return $formBuilder->render($this); } /** * 編輯 * @return string * @author cleverstone * @since 1.0 */ public function actionEdit() { $formBuilder = ViewBuilder::form(); $formBuilder->partial = true; return $formBuilder->render($this); } /** * 禁用 * @return mixed * @author cleverstone * @since 1.0 */ public function actionDisable() { $bodyParams = $this->post; $idMap = explode(',', $bodyParams['id']); $statusMap = array_map(function ($value) { return $value == 0 ? 1 : 0; }, explode(',', $bodyParams['status'])); $dataMap = array_combine($idMap, $statusMap); foreach ($dataMap as $id => $status) { $model = AdminUser::findOne(['id' => $id]); $model->status = $status; $model->save(); } return $this->asSuccess([], '操作成功'); } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看