| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace App\Admin\Actions\Users;
- use App\Models\UserInfoModel;
- use Dcat\Admin\Contracts\LazyRenderable;
- use Dcat\Admin\Traits\LazyWidget;
- use Dcat\Admin\Widgets\Form;
- class UsersInfoForm extends Form implements LazyRenderable
- {
- use LazyWidget;
- public function __construct($data = [], $key = null)
- {
- parent::__construct($data, $key);
- }
- public function handle(array $input)
- {
- $user_info = UserInfoModel::query()->find($input['user_id']);
- if (!$user_info) {
- return $this->response()->error('请刷新后重试');
- }
- $user_info->update($input);
- return $this->response()->success('保存成功')->refresh();
- }
- public function form()
- {
- if (request()->ajax()) {
- $user_info = UserInfoModel::query()->where('user_id', $this->payload['user_id'])->first();
- $this->fill($user_info);
- }
- $this->text('user_id', "用户ID")->readOnly();
- $this->text('nickname', '昵称')->required();
- $this->image('avatar', '头像')->disk('oss')->saveFullUrl()->uniqueName()->removable(false)->autoUpload();
- $this->text('weixin', '微信号');
- $this->text('birthday', '生日');
- $this->text('height', '身高');
- $this->text('weight', '体重');
- $this->text('work', '职业');
- $this->text('info', '个人简介');
- $this->text('area', '所在地区')->default("成都市");
- $this->text('figure', '身材');
- $this->text('feeling', '感情状态');
- $this->text('education', '学历');
- $this->text('income', '年收入');
- $this->text('hobby', '兴趣爱好')->help("多个字段用,隔开,例如:唱歌,跳舞");
- $this->text('drink', '喝酒');
- $this->text('smoke', '抽烟');
- $this->array('photo', function (Form $form) {
- $form->image('url', '图片')->disk("oss")->saveFullUrl()->uniqueName()->removable(false)->autoUpload()->on('startUpload', <<<JS
- function () {
- console.log('文件开始上传...', this);
- // 上传文件前附加自定义参数到文件上传接口
- this.uploader.options.formData['custom_field'] = '...';
- }
- JS
- )
- ->on('uploadFinished', <<<JS
- function () {
- console.log('文件上传完毕');
- }
- JS
- );;
- $form->radio('state', '阅后即焚')->options([0 => "否", 1 => "是"])->default(0);
- })->saveAsJson()->label('相册');
- $this->file('video', '视频')->saveAsJson();
- }
- }
|