6 changed files with 193 additions and 8 deletions
			
			
		- 
					108app/Admin/Controllers/v3/StoreUserController.php
 - 
					16app/Admin/Repositories/v3/StoreUser.php
 - 
					1app/Admin/routes.php
 - 
					40app/Models/v3/StoreUser.php
 - 
					16dcat_admin_ide_helper.php
 - 
					20resources/lang/zh-CN/store-user.php
 
@ -0,0 +1,108 @@ | 
			
		|||||
 | 
				<?php | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				namespace App\Admin\Controllers\v3; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				use App\Admin\Repositories\v3\StoreUser; | 
			
		||||
 | 
				use Dcat\Admin\Form; | 
			
		||||
 | 
				use Dcat\Admin\Grid; | 
			
		||||
 | 
				use Dcat\Admin\Show; | 
			
		||||
 | 
				use Dcat\Admin\Controllers\AdminController; | 
			
		||||
 | 
				use App\Models\v3\Store as StoreModel; | 
			
		||||
 | 
				use App\Models\v3\StoreUser as StoreUserModel; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				class StoreUserController extends AdminController | 
			
		||||
 | 
				{ | 
			
		||||
 | 
				    /** | 
			
		||||
 | 
				     * Make a grid builder. | 
			
		||||
 | 
				     * | 
			
		||||
 | 
				     * @return Grid | 
			
		||||
 | 
				     */ | 
			
		||||
 | 
				    protected function grid() | 
			
		||||
 | 
				    { | 
			
		||||
 | 
				        return Grid::make(new StoreUser(), function (Grid $grid) { | 
			
		||||
 | 
				            // 店铺
 | 
			
		||||
 | 
				            $storeList = StoreModel::getStoreArray(); | 
			
		||||
 | 
				            // 账号类型
 | 
			
		||||
 | 
				            $categoryList = StoreUserModel::$_USER_CATEGORY; | 
			
		||||
 | 
				            // 注册类型
 | 
			
		||||
 | 
				            $typeList = StoreUserModel::$_USER_CATEGORY; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				            $grid->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); | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				        }); | 
			
		||||
 | 
				    } | 
			
		||||
 | 
				} | 
			
		||||
@ -0,0 +1,16 @@ | 
			
		|||||
 | 
				<?php | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				namespace App\Admin\Repositories\v3; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				use App\Models\v3\StoreUser as Model; | 
			
		||||
 | 
				use Dcat\Admin\Repositories\EloquentRepository; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				class StoreUser extends EloquentRepository | 
			
		||||
 | 
				{ | 
			
		||||
 | 
				    /** | 
			
		||||
 | 
				     * Model. | 
			
		||||
 | 
				     * | 
			
		||||
 | 
				     * @var string | 
			
		||||
 | 
				     */ | 
			
		||||
 | 
				    protected $eloquentClass = Model::class; | 
			
		||||
 | 
				} | 
			
		||||
@ -0,0 +1,40 @@ | 
			
		|||||
 | 
				<?php | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				namespace App\Models\v3; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				use Dcat\Admin\Traits\HasDateTimeFormatter; | 
			
		||||
 | 
				use Illuminate\Database\Eloquent\SoftDeletes; | 
			
		||||
 | 
				use Illuminate\Database\Eloquent\Model; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				class StoreUser extends Model | 
			
		||||
 | 
				{ | 
			
		||||
 | 
					use HasDateTimeFormatter; | 
			
		||||
 | 
				    use SoftDeletes; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				    protected $table = 'lanzu_store_users'; | 
			
		||||
 | 
				    protected $dateFormat = 'U'; | 
			
		||||
 | 
				    protected $appends = [ | 
			
		||||
 | 
				        'user_category_text', | 
			
		||||
 | 
				        'register_type_text', | 
			
		||||
 | 
				        'status_text' | 
			
		||||
 | 
				    ]; | 
			
		||||
 | 
				    public static $_USER_CATEGORY = ['管理员','店长', 2=>'店员']; | 
			
		||||
 | 
				    public static $_REGISTER_TYPE = ['网站注册','QQ','微信','app','商户注册默认账号','后台添加商户账号']; | 
			
		||||
 | 
				    public static $_STATUS = ['禁用','审核中', '正常']; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				    public function getUserCategoryTextAttribute($value) | 
			
		||||
 | 
				    { | 
			
		||||
 | 
				        $value = $value ? $value : $this->user_category; | 
			
		||||
 | 
				        return isset(self::$_USER_CATEGORY[$value]) ? self::$_USER_CATEGORY[$value] : ''; | 
			
		||||
 | 
				    } | 
			
		||||
 | 
				    public function getRegisterTypeTextAttribute($value) | 
			
		||||
 | 
				    { | 
			
		||||
 | 
				        $value = $value ? $value : $this->register_type; | 
			
		||||
 | 
				        return isset(self::$_REGISTER_TYPE[$value]) ? self::$_REGISTER_TYPE[$value] : ''; | 
			
		||||
 | 
				    } | 
			
		||||
 | 
				    public function getStatusTextAttribute($value) | 
			
		||||
 | 
				    { | 
			
		||||
 | 
				        $value = $value ? $value : $this->status; | 
			
		||||
 | 
				        return isset(self::$_STATUS[$value]) ? self::$_STATUS[$value] : ''; | 
			
		||||
 | 
				    } | 
			
		||||
 | 
				} | 
			
		||||
@ -0,0 +1,20 @@ | 
			
		|||||
 | 
				<?php  | 
			
		||||
 | 
				return [ | 
			
		||||
 | 
				    'labels' => [ | 
			
		||||
 | 
				        'StoreUser' => '店铺账号', | 
			
		||||
 | 
				        'StoreUser' => '店铺账号', | 
			
		||||
 | 
				        'store_User' => '店铺账号', | 
			
		||||
 | 
				    ], | 
			
		||||
 | 
				    'fields' => [ | 
			
		||||
 | 
				        'store_id' => '商家id', | 
			
		||||
 | 
				        'username' => '账号', | 
			
		||||
 | 
				        'user_category' => '账号类型', | 
			
		||||
 | 
				        'register_type' => '用户来源类型', | 
			
		||||
 | 
				        'status' => '状态', | 
			
		||||
 | 
				        'join_ip' => '注册IP', | 
			
		||||
 | 
				        'last_visit_time' => '最后访问时间', | 
			
		||||
 | 
				        'last_ip' => '最后访问IP', | 
			
		||||
 | 
				    ], | 
			
		||||
 | 
				    'options' => [ | 
			
		||||
 | 
				    ], | 
			
		||||
 | 
				]; | 
			
		||||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue