Pass.php 865 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Admin\Actions\Community\Docter;
  3. use App\Models\Docter;
  4. use App\Models\DocterOrganization;
  5. use Encore\Admin\Actions\RowAction;
  6. use Encore\Admin\Grid\Model;
  7. use Illuminate\Http\Request;
  8. class Pass extends RowAction
  9. {
  10. public $name = '通过';
  11. public function handle()
  12. {
  13. $id = $this->row->id;
  14. $docter_id = $this->row->docter_id;
  15. try{
  16. $DocOrg = new DocterOrganization();
  17. $DocOrg->where('id',$id)->update(['state'=>1]);
  18. $count = $DocOrg->where('state','!=',1)->count();
  19. if($count == 0){
  20. Docter::where(['id'=>$docter_id])->update(['is_then'=>1]);
  21. }
  22. } catch (\Exception $e){
  23. return $this->response()->error('更新失败!');
  24. }
  25. return $this->response()->success('更新成功')->refresh();
  26. }
  27. }