Пример #1
0
 public function getRolePermissionEditor(Request $request)
 {
     $table = new Table();
     $table->setId('admin.user.role.permission.editor');
     $table->setHelpStatusListener($request);
     $permissions = DB::table('permission_role as one')->where('role_id', $request->input('role'))->join('permissions as two', 'one.permission_id', '=', 'two.id')->select('two.id', 'two.name', 'two.display_name')->get();
     $exist = [];
     foreach ($permissions as $permission) {
         array_push($exist, $permission->id);
     }
     $data['exist'] = $exist;
     $data['helpLink'] = true;
     $data['helpStatus'] = $table->getHelpStatus();
     $data['active'] = 'roles';
     $data['role'] = Roles::find($request->input('role'))->toArray();
     $data['permissions'] = Permissions::get();
     $data['tip'] = '左边选项是权限列表,右边权限是当下角色拥有的权限。';
     if ($request->input('table_submit') != 'change-help-status') {
         return view('admin.user.editor.role-permission', $data);
     }
 }
Пример #2
0
 public function getPages(Request $request)
 {
     $user = getUser();
     $table = new Table();
     $table->setId('admin.page.pages');
     $table->setDatabase(['table' => 'pages', 'where' => ['pages.user_id', $user['id']], 'orWhere' => ['pages.status', 'open'], 'join' => ['pages as father', 'pages.page_id', '=', 'father.id'], 'select' => ['pages.id', 'pages.user_id', 'pages.page_id', 'pages.level', 'pages.alias', 'pages.title', 'pages.cover', 'pages.content', 'pages.keywords', 'pages.description', 'pages.created_at', 'pages.updated_at', 'pages.status', 'father.title as ftitle']]);
     $table->setFields(['title' => '页面标题', 'page_id' => '父页面', 'status' => '状态', 'keywords' => '关键字', 'description' => '描述', 'created_at' => '添加时间', 'updated_at' => '更新时间', 'options' => '操作']);
     $table->setPrimary('title');
     $table->setFieldWidth(['title' => '30%']);
     $table->setFieldCallbacks(['title' => function ($row) {
         $title = '';
         for ($i = 1; $i < $row['level']; $i++) {
             $title .= ' —';
         }
         $title .= ' ' . $row['title'];
         return $title;
     }, 'status' => function ($row) {
         switch ($row['status']) {
             case 'open':
                 return '<span style="color:green;">共享</span>';
                 break;
             case 'public':
                 return '<span style="color:green;">公开</span>';
                 break;
             case 'draft':
                 return '草稿';
                 break;
         }
     }, 'keywords' => function ($row) {
         if ($row['keywords'] == '') {
             return '-';
         }
     }, 'description' => function ($row) {
         if ($row['description'] == '') {
             return '-';
         }
     }, 'page_id' => function ($row) {
         if ($row['id'] == $row['page_id']) {
             return '无';
         } else {
             return $row['ftitle'];
         }
     }, 'options' => function ($row) {
         return '<a href="/admin/page/editor?edit=' . $row['id'] . '&token=' . csrf_token() . '">编辑</a> ' . '<a style="color:red;" class="delete-link" href="/admin/page/delete?id=' . $row['id'] . '&token=' . csrf_token() . '">删除</a> ';
     }]);
     $table->setSelects([['name' => 'multi', 'options' => ['multi' => '批量操作', 'delete' => '删除'], 'applyName' => 'multi']]);
     $table->setSearch(['type' => 'title', 'types' => ['title' => '标题', 'keywords' => '关键字', 'id' => 'ID']]);
     $table->init($request);
     $data['table'] = $table->getHtml();
     $data['helpStatus'] = $table->getHelpStatus();
     $data['optionLink'] = true;
     $data['helpLink'] = true;
     $data['active'] = 'pages';
     $data['tip'] = '页面管理';
     if ($redirect = $this->dealMulti($request)) {
         return $redirect;
     }
     return view('admin.page.pages', $data);
 }