Supplier.php 923 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Model;
  3. use App\Scopes\DepartmentScope;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Supplier extends Model
  6. {
  7. // protected $fillable = [];
  8. protected $guarded = [];
  9. protected $table = "supplier"; //指定表
  10. const CREATED_AT = 'crt_time';
  11. const UPDATED_AT = 'upd_time';
  12. protected $dateFormat = 'U';
  13. const is_main = 1;//是否总供应商
  14. public static $user = [];
  15. public static $search = [];
  16. const range_function = 'supplierRange';
  17. public function __construct(array $attributes = [])
  18. {
  19. if(! empty($attributes['userData'])) {
  20. self::$user = $attributes['userData'];
  21. self::$user['range_function'] = self::range_function;
  22. self::$search = $attributes['search'] ?? [];
  23. static::addGlobalScope(new DepartmentScope(self::$user, self::$search));
  24. }
  25. parent::__construct($attributes);
  26. }
  27. }