Files
pingan_unionpay_new/app/Admin/Actions/User/Callback.php
2021-01-31 11:50:56 +08:00

43 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Admin\Actions\User;
use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
class Callback extends RowAction
{
public $name = '设置回调地址';
public function handle(Model $model, Request $request)
{
$validator = \Validator::make($request->all(), [
'callback' => 'required|url',
], [
'callback.required' => '缺少回调地址',
'callback.url' => '回调地址不正确不是有效的url地址',
]);
if ($validator->fails()) {
return $this->response()->error($validator->errors()->first());
}
$model->callback = $request->callback;
if ($model->save()) {
return $this->response()->success('设置成功')->refresh();
}
return $this->response()->error('设置失败')->refresh();
}
public function form(Model $model)
{
$this->text('callback', '回调地址')->default($model->callback)->required();
}
}