123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace App\Admin\Actions\Users;
- use App\Models\User;
- use App\Models\UserVipLogModel;
- use App\Models\VipModel;
- use Dcat\Admin\Contracts\LazyRenderable;
- use Dcat\Admin\Traits\LazyWidget;
- use Dcat\Admin\Widgets\Form;
- use Illuminate\Support\Facades\DB;
- use PHPUnit\Util\Exception;
- class UserAuthForm extends Form implements LazyRenderable
- {
- use LazyWidget;
- public function __construct($data = [], $key = null)
- {
- parent::__construct($data, $key);
- }
- public function handle(array $input)
- {
- DB::beginTransaction();
- try {
- $user = User::query()->find($input['id']);
- if(!$user){
- throw new Exception("请刷新后重试");
- }
- $user->is_auth = $input['is_auth'];
- $user->save();
- DB::commit();
- }catch (\Exception $exception){
- DB::rollBack();
- return $this->response()->error($exception->getMessage());
- }
- return $this->response()->success('保存成功')->refresh();
- }
- public function form()
- {
- $this->hidden('id')->value($this->payload['id']);
- $this->select('is_auth', '认证等级')->options([0=>'未认证',1=>'真人认证',2=>"女神认证"]);
- }
- }
|