InvoiceOrder.php 1023 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Model;
  3. use App\Scopes\DepartmentScope;
  4. use Illuminate\Database\Eloquent\Model;
  5. class InvoiceOrder extends Model
  6. {
  7. protected $fillable = ['userData'];
  8. protected $table = "invoice_order"; //指定表
  9. const CREATED_AT = 'crt_time';
  10. const UPDATED_AT = 'upd_time';
  11. protected $dateFormat = 'U';
  12. const STATE_ZERO = 0;//未确认
  13. const STATE_ONE = 1;//已确认
  14. const prefix = 'FH';
  15. public static $name = [
  16. 0 => '未确认',
  17. 1 => '已确认',
  18. ];
  19. public static $user = [];
  20. public static $is_search = false;
  21. public function __construct(array $attributes = [])
  22. {
  23. if(! empty($attributes['userData'])) {
  24. self::$user = $attributes['userData'];
  25. self::$is_search = true;
  26. }
  27. parent::__construct($attributes);
  28. }
  29. protected static function boot(){
  30. parent::boot();
  31. if(self::$is_search){
  32. static::addGlobalScope(new DepartmentScope(self::$user));
  33. }
  34. }
  35. }