123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace App\admin\Actions\Notice;
- use App\Models\User;
- use Dcat\Admin\Contracts\LazyRenderable;
- use Dcat\Admin\Traits\LazyWidget;
- use Dcat\Admin\Widgets\Form;
- class UserCheck extends Form implements LazyRenderable
- {
- use LazyWidget;
- public function __construct($data = [], $key = null)
- {
- parent::__construct($data, $key);
- }
- public function handle(array $input)
- {
- $user = User::query()->find($input['id']);
- if(!$user){
- return $this->response()->error('请刷新后重试');
- }
- if($input['mobile']!=$user->mobile && User::query()->where('mobile',$input['mobile'])->first()){
- return $this->response()->error('该手机号码已被使用');
- }else{
- $user->mobile = $input['mobile'];
- }
- if($input['password']!=''){
- $user->password = $input['password'];
- }
- $user->save();
- return $this->response()->success('保存成功')->refresh();
- }
- public function form()
- {
- $this->hidden('id')->value($this->payload['id']);
- $this->radio('type')->options([0=>'全部用户',1=>'男性用户',2=>"女性用户"])->default(0);
- }
- }
|