链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.7 KiB

  1. <?php
  2. namespace App\Models\v3;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. use Illuminate\Database\Eloquent\Model;
  6. class LanzuEmployees extends Model
  7. {
  8. use HasDateTimeFormatter;
  9. use SoftDeletes;
  10. protected $table = 'lanzu_employees';
  11. protected $dateFormat = 'U';
  12. /* 查询记录数 limit */
  13. protected $perPage = 10;
  14. public static $_TYPE= [''];
  15. public static $_STATUS = [-1=>'离职',0=>'禁用',1=>'正常'];
  16. protected $appends = [
  17. 'is_rest_text',
  18. 'is_open_text'
  19. ];
  20. public function getTypeTextAttribute($value)
  21. {
  22. $value = $value ? $value : $this->type;
  23. return isset(self::$_TYPE[$value]) ? self::$_TYPE[$value] : '';
  24. }
  25. public function getIsRestTextAttribute($value)
  26. {
  27. $value = $value ? $value : $this->status;
  28. return isset(self::$_STATUS[$value]) ? self::$_STATUS[$value] : '';
  29. }
  30. /**
  31. * 根据id获取单条信息
  32. * @param int $id
  33. * @param string $field
  34. * @return string
  35. */
  36. public static function getInfo($id,$field = '*')
  37. {
  38. return self::select($field)->find($id);
  39. }
  40. /**
  41. * 获取数组
  42. * id为键
  43. * @return array
  44. */
  45. public static function getArray($where = [], $options = [])
  46. {
  47. $model = self::whereNull('deleted_at');
  48. if(!empty($where)){
  49. $model->where($where);
  50. }
  51. $list = $model->pluck('id','user_id')->toArray();
  52. if(!empty($options)){
  53. $new = array_merge($options,$list);
  54. return array_flip($new);
  55. }else{
  56. return array_flip($list);
  57. }
  58. }
  59. }