DoReply.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Admin\Actions\Problem;
  3. use App\Models\User;
  4. use App\Models\UserProblemModel;
  5. use Dcat\Admin\Contracts\LazyRenderable;
  6. use Dcat\Admin\Traits\LazyWidget;
  7. use Dcat\Admin\Widgets\Form;
  8. use PHPUnit\Util\Exception;
  9. class DoReply extends Form implements LazyRenderable
  10. {
  11. use LazyWidget;
  12. public function __construct($data = [], $key = null)
  13. {
  14. parent::__construct($data, $key);
  15. }
  16. public function handle(array $input)
  17. {
  18. $problem = UserProblemModel::query()->find($input['id']);
  19. if(!$problem){
  20. return $this->response()->error('请刷新后重试');
  21. }
  22. if(empty($input['reply'])){
  23. return $this->response()->error('请输入回复内容');
  24. }
  25. $problem->status = 1;
  26. $problem->reply = $input['reply'];
  27. $problem->save();
  28. return $this->response()->success('保存成功')->refresh();
  29. }
  30. public function form()
  31. {
  32. $this->hidden('id')->value($this->payload['id']);
  33. $this->textarea('reply', '回复内容');
  34. }
  35. }