1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace App\Admin\Actions\Grid\User;
- use App\Admin\Forms\User\UserPaycodeForm;
- use Dcat\Admin\Actions\Response;
- use Dcat\Admin\Grid\RowAction;
- use Dcat\Admin\Traits\HasPermissions;
- use Dcat\Admin\Widgets\Modal;
- use Illuminate\Contracts\Auth\Authenticatable;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Http\Request;
- class UserPaycodeUpdateAction extends RowAction
- {
- /**
- * @return string
- */
- protected $title = '支付密码';
- public function render()
- {
- $form = UserPaycodeForm::make()->payload(["id"=>$this->getKey()]);
- return Modal::make()
- ->lg()
- ->title($this->title)
- ->body($form)
- // 因为此处使用了表单异步加载功能,所以一定要用 onLoad 方法
- // 如果是非异步方式加载表单,则需要改成 onShow 方法
- ->button($this->title);
- }
- /**
- * Handle the action request.
- *
- * @param Request $request
- *
- * @return Response
- */
- public function handle(Request $request)
- {
- // dump($this->getKey());
- return $this->response()
- ->success('Processed successfully: '.$this->getKey())
- ->redirect('/');
- }
- /**
- * @return string|array|void
- */
- public function confirm()
- {
- // return ['Confirm?', 'contents'];
- }
- /**
- * @param Model|Authenticatable|HasPermissions|null $user
- *
- * @return bool
- */
- protected function authorize($user): bool
- {
- return true;
- }
- /**
- * @return array
- */
- protected function parameters()
- {
- return [];
- }
- }
|