|
|
@ -56,9 +56,12 @@ class AgentController extends AdminController |
|
|
UserStatus::DISABLED => 'warning', |
|
|
UserStatus::DISABLED => 'warning', |
|
|
], 'primary'); |
|
|
], 'primary'); |
|
|
|
|
|
|
|
|
$grid->filter(function (Grid\Filter $filter) { |
|
|
|
|
|
$filter->equal('id'); |
|
|
|
|
|
|
|
|
$grid->filter(function ($filter) { |
|
|
|
|
|
$filter->panel(); |
|
|
|
|
|
|
|
|
|
|
|
$filter->equal('id')->width(2); |
|
|
|
|
|
$filter->like('agent_name')->width(3); |
|
|
|
|
|
$filter->equal('status', '用户状态')->select(UserStatus::array())->width(2); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
@ -72,7 +75,7 @@ class AgentController extends AdminController |
|
|
*/ |
|
|
*/ |
|
|
protected function detail($id) |
|
|
protected function detail($id) |
|
|
{ |
|
|
{ |
|
|
return Show::make($id, new Agent(), function (Show $show) { |
|
|
|
|
|
|
|
|
return Show::make($id, new Agent('agentInfo'), function (Show $show) { |
|
|
$show->disableDeleteButton(); |
|
|
$show->disableDeleteButton(); |
|
|
|
|
|
|
|
|
$show->field('id'); |
|
|
$show->field('id'); |
|
|
@ -90,6 +93,21 @@ class AgentController extends AdminController |
|
|
$show->field('license_pic')->image(120, 120); |
|
|
$show->field('license_pic')->image(120, 120); |
|
|
$show->field('director'); |
|
|
$show->field('director'); |
|
|
$show->field('contact_phone'); |
|
|
$show->field('contact_phone'); |
|
|
|
|
|
$show->field('agentInfo.about', '关于我们') |
|
|
|
|
|
->unescape() |
|
|
|
|
|
->as(function ($v) { |
|
|
|
|
|
return preg_replace('/<script.*?>.*?<\/script>/is', '', $this->agentInfo->about); |
|
|
|
|
|
}); |
|
|
|
|
|
$show->field('agentInfo.reg_protocol', '注册协议') |
|
|
|
|
|
->unescape() |
|
|
|
|
|
->as(function ($v) { |
|
|
|
|
|
return preg_replace('/<script.*?>.*?<\/script>/is', '', $this->agentInfo->reg_protocol); |
|
|
|
|
|
}); |
|
|
|
|
|
$show->field('agentInfo.buy_protocol', '购买协议') |
|
|
|
|
|
->unescape() |
|
|
|
|
|
->as(function ($v) { |
|
|
|
|
|
return preg_replace('/<script.*?>.*?<\/script>/is', '', $this->agentInfo->buy_protocol); |
|
|
|
|
|
}); |
|
|
$show->field('created_at')->as(fn($v) => date('Y-m-d H:i:s', $v)); |
|
|
$show->field('created_at')->as(fn($v) => date('Y-m-d H:i:s', $v)); |
|
|
$show->field('updated_at')->as(fn($v) => date('Y-m-d H:i:s', $v)); |
|
|
$show->field('updated_at')->as(fn($v) => date('Y-m-d H:i:s', $v)); |
|
|
}); |
|
|
}); |
|
|
@ -106,8 +124,15 @@ class AgentController extends AdminController |
|
|
$form->disableDeleteButton(); |
|
|
$form->disableDeleteButton(); |
|
|
|
|
|
|
|
|
$form->display('id'); |
|
|
$form->display('id'); |
|
|
|
|
|
//新增
|
|
|
|
|
|
if ($form->isCreating()) { |
|
|
$form->text('account')->required(); |
|
|
$form->text('account')->required(); |
|
|
$form->text('password')->required(); |
|
|
$form->text('password')->required(); |
|
|
|
|
|
} |
|
|
|
|
|
else if ($form->isEditing()) { |
|
|
|
|
|
$form->display('account'); |
|
|
|
|
|
$form->text('password')->customFormat(fn() => ''); |
|
|
|
|
|
} |
|
|
$form->text('agent_name')->required(); |
|
|
$form->text('agent_name')->required(); |
|
|
$form->text('appid')->required(); |
|
|
$form->text('appid')->required(); |
|
|
$form->text('appsecret')->required(); |
|
|
$form->text('appsecret')->required(); |
|
|
@ -123,7 +148,9 @@ class AgentController extends AdminController |
|
|
$form->image('license_pic'); |
|
|
$form->image('license_pic'); |
|
|
$form->text('director'); |
|
|
$form->text('director'); |
|
|
$form->text('contact_phone'); |
|
|
$form->text('contact_phone'); |
|
|
$form->textarea('agentInfo.about'); |
|
|
|
|
|
|
|
|
$form->editor('agentInfo.about', '关于我们');// 隐藏菜单用:->options(['menubar' => false]);
|
|
|
|
|
|
$form->editor('agentInfo.reg_protocol', '注册协议'); |
|
|
|
|
|
$form->editor('agentInfo.buy_protocol', '购买协议'); |
|
|
})->saving(function (Form $form) { |
|
|
})->saving(function (Form $form) { |
|
|
//不允许编辑的字段
|
|
|
//不允许编辑的字段
|
|
|
if ($form->isEditing()) { |
|
|
if ($form->isEditing()) { |
|
|
@ -132,9 +159,22 @@ class AgentController extends AdminController |
|
|
|
|
|
|
|
|
//过滤null字段
|
|
|
//过滤null字段
|
|
|
foreach($form->input() as $k => $v) { |
|
|
foreach($form->input() as $k => $v) { |
|
|
if (is_null($form->$k)) { |
|
|
|
|
|
|
|
|
if (is_null($v)) { |
|
|
$form->$k = ''; |
|
|
$form->$k = ''; |
|
|
|
|
|
} else if (is_array($v)) { |
|
|
|
|
|
foreach ($v as $k2 => &$v2) { |
|
|
|
|
|
if (is_null($v2)) { |
|
|
|
|
|
$v2 = ''; //不能用$form->$k[$k2] = '',会报错,只能通过引用修改
|
|
|
|
|
|
} else { |
|
|
|
|
|
$v2 = preg_replace('/<script.*?>.*?<\/script>/is', '', $v2); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
})->saved(function (Form $form) { |
|
|
|
|
|
//如果状态是正常,插入初始数据
|
|
|
|
|
|
if ($form->status == UserStatus::NORMAL) { |
|
|
|
|
|
(new AuditAgent)->setKey($form->getKey())->pass(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|