jingcai-php/app/Admin/Forms/PayChannelTokenForm.php

52 lines
1.6 KiB
PHP

<?php
namespace App\Admin\Forms;
use App\Model\Seller\ShopPayChannel;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;
use Illuminate\Support\Arr;
use Log;
class PayChannelTokenForm extends Form implements LazyRenderable
{
use LazyWidget;
public function handle(array $input)
{
$id = Arr::get($input, 'id');
if (!$id) {
return $this->response()->alert()->error('参数有误');
}
$payChannel = ShopPayChannel::find($id);
if (!$payChannel) {
return $this->response()->alert()->error('数据不存在!');
}
$token = Arr::get($input, 'ali_face_app_auth_token');
if (!$token) {
return $this->response()->alert()->error('token 必填!');
}
$payChannel->ali_face_app_auth_token = $token;
$payChannel->save();
return $this->response()->success("设置成功")->refresh();
}
public function form()
{
$id = $this->payload['id'];
$payChannel = ShopPayChannel::find($id);
if (!$payChannel) {
return $this->response()->alert()->error('数据不存在!');
}
$this->display('shop_name','店铺编号')->value($payChannel->shop->shop_sn);
$this->display('alipay','支付宝账号')->value($payChannel->alipay);
$this->display('pay_channel','支付宝渠道')->value($payChannel->channel_name);
$this->text('ali_face_app_auth_token', '支付宝Token')->required();
$this->hidden('id')->value($id);
}
}