Failed.php 886 B

1234567891011121314151617181920212223242526272829303132
  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. DB::beginTransaction();
  17. try {
  18. DocterOrganization::where('id',$this->row->id)->update(['state'=>2]);
  19. $docter_id = $this->row->docter_id;
  20. Docter::where(['id'=>$docter_id])->update(['is_then'=>0]);
  21. DB::commit();
  22. } catch (Exception $e){
  23. DB::rollBack();
  24. return $this->response()->error('操作失败');
  25. }
  26. return $this->response()->success('操作成功')->refresh();
  27. }
  28. }