链街Dcat后台
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.
 
 
 
 

78 lines
2.0 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\Form\NestedForm;
class ProgramShareCardForm extends Form
{
/**
* Handle the form request.
*
* @param array $input
*
* @return Response
*/
public function handle(array $input)
{
// 获取外部传递参数
$data = $input['share_card'];
$data[0]['image'] = '';
foreach($data as &$value){
$value = json_encode($value);
}
// dd($data);
$res = Redis::hmset(RedisKey::PROGRAM_SHARE_CARD , $data);
if($res){
return $this->success('修改成功','/share_card_setting');
}else{
return $this->error('修改失败');
}
}
/**
* Build a form here.
*/
public function form()
{
$data = Redis::hgetall(RedisKey::PROGRAM_SHARE_CARD);
$this->display('setting' , '设置')->value('小程序分享卡片设置');
foreach($data as &$value){
$value = json_decode($value,true);
// dd($data);
$this->table('share_card', function (NestedForm $table) use($value){
$table->text('title','标题')->value($value['title'])->width(10);
$table->image('image','图片')->autoUpload()->width(2)
->customFormat(function() use($value){
return [$value['image']];
});
});
}
// $this->hasMany('share_card', function (NestedForm $form) {
// $form->text('title','标题')->required()->default('');
// $form->image('image','图片')->autoUpload()->saveFullUrl()->width(3);
// });
// $this->image('img');->saveFullUrl()
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
return [];
}
}