protected function _init_table()
 {
     $table = new KTable();
     //$table->title( '管理员角色列表' );
     $table->th('角色名')->searchable('name')->functional(function ($role) {
         return e($role->name);
     })->th('描述')->searchable('title')->functional(function ($role) {
         return e($role->title);
     })->th('操作')->functional(function ($role) {
         return static::block_btn_groups($role);
     });
     return $table;
 }
Exemplo n.º 2
0
    /**
     * 展示某一个资源的操作记录
     * @param $item 需要展示历史记录的resource
     * @return KPanel 以panel形式返回操作记录
     */
    public static function adminHistoryPanel($item)
    {
        $panel = new KPanel(KPanel::STYLE_WARNING);
        $panel->title('历史操作记录');
        $panel->collapse();
        $table = new KTable();
        $table->th('发生时间')->functional(function (HistoryModel $record) {
            return e($record->created_at);
        })->th('操作者')->functional(function (HistoryModel $record) {
            $operator = $record->operator;
            if ($operator) {
                return e($operator->username);
            } else {
                return '匿名操作';
            }
        })->th('涉及表格')->functional(function (HistoryModel $record) {
            return e($record->table . '.' . $record->resource_id);
        })->th('动作')->functional(function (HistoryModel $record) {
            return e($record->action);
        })->th('旧数据')->functional(function (HistoryModel $record) {
            $records = HistoryModel::unserialize($record->old);
            $html = '';
            foreach ($records as $key => $val) {
                $key = json_encode($key);
                $val = json_encode($val);
                $html .= <<<HTML
<span class="label label-warning">{$key}:{$val}</span>
HTML;
                return $html;
            }
        })->th('新数据')->functional(function (HistoryModel $record) {
            $records = HistoryModel::unserialize($record->new);
            $html = '';
            foreach ($records as $key => $val) {
                $key = e($key);
                $val = e($val);
                $html .= <<<HTML
<span class="label label-success">{$key}:{$val}</span>
HTML;
                return $html;
            }
        });
        $table->itemsToTbody($item->histories);
        $panel->content($table);
        return $panel;
    }
Exemplo n.º 3
0
 /**
  * 产生列表页的列表
  * @param $table KTable()
  * @param $items Illuminate\Pagination\Paginator 分页排序后的详细数据
  */
 protected function _index_table(KTable $table, $items)
 {
     $table->itemsToTbody($items);
 }
 /**
  * 生成详情页面
  * @param $item
  * @return array  An array of panels
  */
 protected function _show($item)
 {
     $panel = new KPanel(KPanel::STYLE_PRIMARY);
     $panel->title('用户详情');
     $table = new KTable();
     $table->th('姓名')->setWidth('10%')->th('邮件')->setWidth('10%')->th('手机')->setWidth('10%')->th('创建时间')->setWidth('10%')->th('上次登录时间')->setWidth('10%')->td($item->username)->td($item->email)->td($item->mobile)->td($item->created_at)->td($item->last_login)->tr();
     $panel->content($table);
     return [$panel];
 }