ProductCategory.php 759 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App\Model;
  3. use App\Scopes\TopDepartmentScope;
  4. use Illuminate\Database\Eloquent\Model;
  5. class ProductCategory extends Model
  6. {
  7. protected $guarded = [];
  8. protected $table = "product_category"; //指定表
  9. const CREATED_AT = 'crt_time';
  10. const UPDATED_AT = 'upd_time';
  11. protected $dateFormat = 'U';
  12. public static $user = [];
  13. public static $search = [];
  14. public function __construct(array $attributes = [])
  15. {
  16. if(! empty($attributes['userData'])) {
  17. self::$user = $attributes['userData'];
  18. self::$search = $attributes['search'] ?? [];
  19. static::addGlobalScope(new TopDepartmentScope(self::$user, self::$search));
  20. }
  21. parent::__construct($attributes);
  22. }
  23. }