ProjectRole.php 991 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Models;
  3. class ProjectRole extends BaseModel
  4. {
  5. /**
  6. * @param $key
  7. * 工区负责人(work)
  8. * 机电负责人(machine)
  9. * 项目副经理(assist)
  10. * 项目经理(manager)
  11. * 管理员子账号(sub)
  12. * 领导账号(leader)
  13. * 管理员(admin)
  14. * @param $column
  15. * @return mixed
  16. */
  17. public static function getByKey($key, $column = null)
  18. {
  19. $role = self::where('key', $key)->first();
  20. if($column) return $role ? $role[$column] : '';
  21. return $role;
  22. }
  23. public function getNext($column = null, $inner = false)
  24. {
  25. $need_check = $inner ? 'need_check_inner' : 'need_check';
  26. $item = $this->where([
  27. [$need_check, '=', 1],
  28. ['id', '>', $this['id']]
  29. ])->first();
  30. return $column ? ($item ? $item[$column] : '') : $item;
  31. }
  32. public static function getOptions()
  33. {
  34. return self::where('id', '>', 0)->get()->toArray();
  35. }
  36. }