Failed.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Admin\Actions\Community\Docter;
  3. use App\Models\Docter;
  4. use App\Models\DocterOrganization;
  5. use Encore\Admin\Actions\Action;
  6. use Encore\Admin\Actions\RowAction;
  7. use Illuminate\Http\Request;
  8. use Illuminate\Support\Facades\DB;
  9. use Mockery\Exception;
  10. class Failed extends RowAction
  11. {
  12. protected $selector = '.failed';
  13. public $name = '驳回';
  14. public function handle()
  15. {
  16. $openid = $this->row->docter->openid;
  17. $data = [
  18. $openid,
  19. '',
  20. '很抱歉,你的医生身份认证失败!',
  21. $this->row->docter->name,
  22. $this->row->organization->name,
  23. $this->row->qualification->name,
  24. $this->row->office->name,
  25. '点击进入小程序查看详情,有疑问请联系管理员!'
  26. ];
  27. DB::beginTransaction();
  28. try {
  29. DocterOrganization::where('id',$this->row->id)->update(['state'=>2]);
  30. if(!empty($openid)){
  31. admin_send_docter_message('then_result',$data);
  32. }
  33. DB::commit();
  34. } catch (Exception $e){
  35. dd($e->getMessage());
  36. DB::rollBack();
  37. return $this->response()->error('操作失败');
  38. }
  39. return $this->response()->success('操作成功')->refresh();
  40. }
  41. }