Construction.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Model;
  3. use App\Scopes\DepartmentScope;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Construction extends Model
  6. {
  7. protected $guarded = [];
  8. protected $table = "construction"; //指定表
  9. const CREATED_AT = 'crt_time';
  10. const UPDATED_AT = 'upd_time';
  11. protected $dateFormat = 'U';
  12. const Model_type_one = 1; // 总部安装
  13. const Model_type_two = 2; // 分社网点安装
  14. public static $model_type = [
  15. self::Model_type_one,
  16. self::Model_type_two,
  17. ];
  18. public static $prefix = [
  19. self::Model_type_one => 'WO0.',
  20. self::Model_type_two => 'T9SH.',
  21. ];
  22. const STATE_ZERO = 0;//未确认
  23. const STATE_ONE = 1;//已确认
  24. public static $name = [
  25. self::STATE_ZERO => '未确认',
  26. self::STATE_ONE => '已确认',
  27. ];
  28. public static $user = [];
  29. public static $search = [];
  30. const range_function = 'constructionRange';
  31. public function __construct(array $attributes = [])
  32. {
  33. if(! empty($attributes['userData'])) {
  34. self::$user = $attributes['userData'];
  35. self::$user['range_function'] = self::range_function;
  36. self::$search = $attributes['search'] ?? [];
  37. static::addGlobalScope(new DepartmentScope(self::$user, self::$search));
  38. }
  39. parent::__construct($attributes);
  40. }
  41. }