You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.8 KiB
70 lines
1.8 KiB
<?php
|
|
|
|
namespace App\Admin\Forms\v3;
|
|
|
|
use Dcat\Admin\Widgets\Form;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use App\Libs\Redis\RedisKey;
|
|
use Dcat\Admin\Contracts\LazyRenderable;
|
|
use Dcat\Admin\Traits\LazyWidget;
|
|
|
|
class ShareCardEditForm extends Form implements LazyRenderable
|
|
{
|
|
use LazyWidget;
|
|
/**
|
|
* Handle the form request.
|
|
*
|
|
* @param array $input
|
|
*
|
|
* @return Response
|
|
*/
|
|
public function handle(array $input)
|
|
{
|
|
$id = $input['id'];
|
|
$ossImageDir = config('filesystems.disks.oss.img_host');
|
|
$data = [
|
|
'id' => $id,
|
|
'title' => $input['title'],
|
|
'image' => $ossImageDir.'/'.$input['image'],
|
|
'relative_path' => $input['image'],
|
|
];
|
|
|
|
$data = json_encode($data);
|
|
|
|
$res = Redis::hset(RedisKey::PROGRAM_SHARE_CARD ,$id, $data);
|
|
if($res !== false){
|
|
return $this->success('修改成功','/share_card_setting');
|
|
}else{
|
|
return $this->error('修改失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Build a form here.
|
|
*/
|
|
public function form()
|
|
{
|
|
$id = $this->payload['id'] ?? 0;
|
|
$title = $this->payload['title'] ?? '';
|
|
$image = $this->payload['image'] ?? '';
|
|
$this->display('setting' , ' ')->value('小程序分享卡片设置');
|
|
$this->hidden('id')->value($id);
|
|
$this->text('title','标题')->required()->value($title);
|
|
$this->image('image','图片')->required()->autoUpload()
|
|
->customFormat(function() use($image){
|
|
return [$image];
|
|
})->width(3);
|
|
}
|
|
|
|
/**
|
|
* The data of the form.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function default()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
}
|