| xqd
@@ -0,0 +1,50 @@
|
|
|
+<?php
|
|
|
+namespace App\Admin\Actions\Users;
|
|
|
+
|
|
|
+use App\Models\User;
|
|
|
+use App\Models\UserInfoModel;
|
|
|
+use Dcat\Admin\Contracts\LazyRenderable;
|
|
|
+use Dcat\Admin\Traits\LazyWidget;
|
|
|
+use Dcat\Admin\Widgets\Form;
|
|
|
+use PHPUnit\Util\Exception;
|
|
|
+
|
|
|
+class UsersInfoForm 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()
|
|
|
+ {
|
|
|
+ $user_info = UserInfoModel::query()->where('user_id',$this->payload['id'])->first();
|
|
|
+ $this->text('user_id')->value($this->payload['id'])->readOnly();
|
|
|
+ $this->text('nickname', '昵称')->value($user_info->nickname);
|
|
|
+ $this->image('avatar', '头像')->value($user_info->avatar);
|
|
|
+
|
|
|
+ }
|
|
|
+}
|