column('id')->sortable(); $grid->column('store_id')->display(function($storeId) use($storeList){ return isset($storeList[$storeId])?$storeList[$storeId]:''; }); $grid->column('username'); $grid->column('user_category')->display(function($userCategory) use($categoryList){ return isset($categoryList[$userCategory])?$categoryList[$userCategory]:''; }); $grid->column('register_type')->display(function($registerType) use($typeList){ return isset($typeList[$registerType])?$typeList[$registerType]:''; }); $grid->column('status'); $grid->column('join_ip'); $grid->column('last_visit_time'); $grid->column('last_ip'); $grid->model()->orderBy('id', 'desc'); // 每页10条 $grid->paginate(10); $grid->filter(function (Grid\Filter $filter) use($categoryList){ unset($categoryList[0]); $filter->equal('id'); $filter->equal('user_category')->select($categoryList); }); }); } /** * Make a show builder. * * @param mixed $id * * @return Show */ protected function detail($id) { return Show::make($id, new StoreUser(), function (Show $show) { $show->field('id'); $show->field('store_id'); $show->field('username'); $show->field('user_category'); $show->field('register_type'); $show->field('status'); $show->field('join_ip'); $show->field('last_visit_time'); $show->field('last_ip'); $show->field('created_at'); $show->field('updated_at'); }); } /** * Make a form builder. * * @return Form */ protected function form() { return Form::make(new StoreUser(), function (Form $form) { // 店铺 $storeList = StoreModel::getStoreArray(); // 账号类型 $categoryList = StoreUserModel::$_USER_CATEGORY; unset($categoryList[0]); $form->display('id'); $form->select('store_id')->options($storeList); $form->text('username'); $form->password('password_'); $form->password('password_confirm')->same('password'); $form->select('user_category')->options($categoryList); $form->hidden('register_type')->default(5); }); } }