Pass.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Admin\Actions\Community\Docter;
  3. use App\Models\CdmsUsers;
  4. use App\Models\Docter;
  5. use App\Models\DocterOrganization;
  6. use Encore\Admin\Actions\RowAction;
  7. use Encore\Admin\Grid\Model;
  8. use Illuminate\Http\Request;
  9. class Pass extends RowAction
  10. {
  11. public $name = '通过';
  12. public function handle()
  13. {
  14. $id = $this->row->id;
  15. $org_id = $this->row->organization_id;
  16. $docter_id = $this->row->docter_id;
  17. $name = $this->row->docter->name;
  18. try{
  19. $DocOrg = new DocterOrganization();
  20. $DocOrg->where('id',$id)->update(['state'=>3]);
  21. // $count = $DocOrg->where('state','!=',1)->where('docter_id',$docter_id)->count();
  22. // if($count == 0){
  23. // Docter::where(['id'=>$docter_id])->update(['is_then'=>1]);
  24. // $user_name = $this->randomkeys(8);
  25. // $data['username'] = $user_name;
  26. // $data['name'] = $name;
  27. // $data['password'] = bcrypt('123456');
  28. // $data['org_id'] = $org_id;
  29. // $data['docter_id'] = $docter_id;
  30. // CdmsUsers::insert($data);
  31. // }
  32. } catch (\Exception $e){
  33. return $this->response()->error('更新失败!');
  34. }
  35. return $this->response()->success('更新成功')->refresh();
  36. }
  37. function randomkeys($length)
  38. {
  39. $key = '';
  40. $pattern = '1234567890abcdefghijklmnopqrstuvwxyz
  41. ABCDEFGHIJKLOMNOPQRSTUVWXYZ';
  42. for($i=0;$i<$length;$i++)
  43. {
  44. $key .= $pattern{mt_rand(0,35)}; //生成php随机数
  45. }
  46. return $key;
  47. }
  48. }