链街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.

61 lines
1.3 KiB

  1. <?php
  2. namespace App\Admin\Forms\v3;
  3. use Dcat\Admin\Widgets\Form;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Illuminate\Support\Facades\Redis;
  6. use App\Libs\Redis\RedisKey;
  7. class ShareCardCreateForm extends Form
  8. {
  9. /**
  10. * Handle the form request.
  11. *
  12. * @param array $input
  13. *
  14. * @return Response
  15. */
  16. public function handle(array $input)
  17. {
  18. $list = Redis::hgetall(RedisKey::PROGRAM_SHARE_CARD);
  19. $id = count($list) + 1;
  20. $data = [
  21. 'id' => $id,
  22. 'title' => $input['title'],
  23. 'image' => $input['image']
  24. ];
  25. $data = json_encode($data);
  26. $res = Redis::hset(RedisKey::PROGRAM_SHARE_CARD ,$id, $data);
  27. if($res){
  28. return $this->success('添加成功','/share_card_setting');
  29. }else{
  30. return $this->error('添加失败');
  31. }
  32. }
  33. /**
  34. * Build a form here.
  35. */
  36. public function form()
  37. {
  38. $this->display('setting' , ' ')->value('小程序分享卡片设置');
  39. $this->text('title','标题')->required();
  40. $this->image('image','图片')->required()->autoUpload()->saveFullUrl()->width(3);
  41. }
  42. /**
  43. * The data of the form.
  44. *
  45. * @return array
  46. */
  47. public function default()
  48. {
  49. return [];
  50. }
  51. }