修改会员管理
parent
3428495fc8
commit
42718e72ff
|
|
@ -19,12 +19,14 @@ class UserController extends AdminController
|
|||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Grid::make(new User(), function (Grid $grid) {
|
||||
$builder = User::with(['userVip', 'userVip.vip']);
|
||||
return Grid::make($builder, function (Grid $grid) {
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('username');
|
||||
// $grid->column('password');
|
||||
$grid->column('phone');
|
||||
$grid->column('email');
|
||||
// $grid->column('username');
|
||||
// $grid->column('password');
|
||||
$grid->column('userVip.vip.name');
|
||||
// $grid->column('email');
|
||||
$grid->column('last_login_ip');
|
||||
$grid->column('last_login_at')->sortable();
|
||||
$grid->column('register_ip');
|
||||
|
|
@ -49,9 +51,7 @@ class UserController extends AdminController
|
|||
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->panel();
|
||||
$filter->like('username')->width(3);
|
||||
$filter->like('phone')->width(3);
|
||||
$filter->like('email')->width(3);
|
||||
// $filter->equal('id');
|
||||
});
|
||||
});
|
||||
|
|
@ -70,9 +70,7 @@ class UserController extends AdminController
|
|||
$row->column(4, function ($column) use ($id) {
|
||||
$column->row(Show::make($id, new User(), function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('username');
|
||||
$show->field('phone');
|
||||
$show->field('email');
|
||||
$show->field('last_login_ip');
|
||||
$show->field('last_login_at');
|
||||
$show->field('register_ip');
|
||||
|
|
@ -102,12 +100,11 @@ class UserController extends AdminController
|
|||
{
|
||||
return Form::make(new User(), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->text('username');
|
||||
$form->mobile('phone')->rules('unique:users,phone');
|
||||
$form->email('email')->rules('unique:users,email');
|
||||
$form->password('password');
|
||||
// $form->text('username');
|
||||
$form->mobile('phone')->rules('unique:users,phone')->required();
|
||||
$form->password('password')->required();
|
||||
// 设置错误信息
|
||||
$form->password('password_confirm')->same('password', '两次密码输入不一致');
|
||||
$form->password('password_confirm')->same('password', '两次密码输入不一致')->required();
|
||||
$form->ignore(['password_confirm']);
|
||||
|
||||
$form->display('created_at');
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ class VipController extends AdminController
|
|||
{
|
||||
return Grid::make(new Vip(), function (Grid $grid) {
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('vip_name');
|
||||
$grid->column('vip_growth_value')->sortable();
|
||||
$grid->column('name');
|
||||
$grid->column('growth_value')->sortable();
|
||||
|
||||
$grid->model()->orderBy('vip_growth_value', 'asc');
|
||||
$grid->model()->orderBy('growth_value', 'asc');
|
||||
|
||||
/** 操作 **/
|
||||
//新增
|
||||
|
|
@ -42,7 +42,7 @@ class VipController extends AdminController
|
|||
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->panel(false);
|
||||
$filter->like('vip_name');
|
||||
$filter->like('name');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -58,8 +58,8 @@ class VipController extends AdminController
|
|||
{
|
||||
return Show::make($id, new Vip(), function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('vip_name');
|
||||
$show->field('vip_growth_value');
|
||||
$show->field('name');
|
||||
$show->field('growth_value');
|
||||
$show->field('created_at');
|
||||
$show->field('updated_at');
|
||||
});
|
||||
|
|
@ -74,8 +74,8 @@ class VipController extends AdminController
|
|||
{
|
||||
return Form::make(new Vip(), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->text('vip_name')->required();
|
||||
$form->number('vip_growth_value')->default(0);
|
||||
$form->text('name')->required();
|
||||
$form->number('growth_value')->default(0);
|
||||
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ class User extends EloquentRepository
|
|||
// foreach ($updates as $column => $value) {
|
||||
// $model->setAttribute($column, $value);
|
||||
// }
|
||||
|
||||
$result = $model::create($updates);
|
||||
$this->model = $model::create($updates);
|
||||
|
||||
$this->updateRelation($form, $model, $relations, $relationKeyMap);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -70,6 +70,16 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac
|
|||
return $this->hasOne(UserInfo::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户的VIP信息
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userVip()
|
||||
{
|
||||
return $this->hasOne(UserVip::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置此用户的密码
|
||||
*
|
||||
|
|
|
|||
|
|
@ -8,4 +8,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class UserVip extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function vip()
|
||||
{
|
||||
return $this->belongsTo(Vip::class, 'vip_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ class CreateVipsTable extends Migration
|
|||
{
|
||||
Schema::create('vips', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('vip_name')->comment('等级名称');
|
||||
$table->unsignedBigInteger('vip_growth_value')->default(0)->comment('等级成长值');
|
||||
$table->string('name')->comment('等级名称');
|
||||
$table->unsignedBigInteger('growth_value')->default(0)->comment('等级成长值');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class CreateUserVipsTable extends Migration
|
|||
$table->id();
|
||||
$table->unsignedBigInteger('user_id')->unique()->comment('用户ID');
|
||||
$table->unsignedBigInteger('vip_id')->comment('会员等级ID');
|
||||
$table->unsignedBigInteger('grow_value')->comment('当前会员成长值');
|
||||
$table->unsignedBigInteger('growth_value')->comment('当前会员成长值');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ return [
|
|||
'vips' => '会员等级',
|
||||
],
|
||||
'fields' => [
|
||||
'vip_name' => '等级名称',
|
||||
'vip_growth_value' => '等级成长值',
|
||||
'name' => '等级名称',
|
||||
'growth_value' => '等级成长值',
|
||||
],
|
||||
'options' => [
|
||||
'deny' => '删除失败',
|
||||
|
|
|
|||
Loading…
Reference in New Issue