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.
61 lines
1.3 KiB
61 lines
1.3 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;
|
|
|
|
class ShareCardCreateForm extends Form
|
|
{
|
|
|
|
/**
|
|
* Handle the form request.
|
|
*
|
|
* @param array $input
|
|
*
|
|
* @return Response
|
|
*/
|
|
public function handle(array $input)
|
|
{
|
|
$list = Redis::hgetall(RedisKey::PROGRAM_SHARE_CARD);
|
|
$id = count($list) + 1;
|
|
$data = [
|
|
'id' => $id,
|
|
'title' => $input['title'],
|
|
'image' => $input['image']
|
|
];
|
|
|
|
$data = json_encode($data);
|
|
|
|
$res = Redis::hset(RedisKey::PROGRAM_SHARE_CARD ,$id, $data);
|
|
if($res){
|
|
return $this->success('添加成功','/share_card_setting');
|
|
}else{
|
|
return $this->error('添加失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Build a form here.
|
|
*/
|
|
public function form()
|
|
{
|
|
$this->display('setting' , ' ')->value('小程序分享卡片设置');
|
|
|
|
$this->text('title','标题')->required();
|
|
$this->image('image','图片')->required()->autoUpload()->saveFullUrl()->width(3);
|
|
}
|
|
|
|
/**
|
|
* The data of the form.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function default()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
}
|