海南旅游SAAS
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.

33 lines
757 B

  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\ModelTree;
  4. use Illuminate\Database\Eloquent\Builder;
  5. use Illuminate\Database\Eloquent\Factories\HasFactory;
  6. class Category extends BaseModel
  7. {
  8. use HasFactory;
  9. use ModelTree;
  10. // 模型树需要的三个属性
  11. protected $parentColumn = 'pid';
  12. protected $orderColumn = 'sort';
  13. protected $titleColumn = 'name';
  14. public function __construct(array $attributes = [])
  15. {
  16. parent::__construct($attributes);
  17. $this->timestamps = false;
  18. }
  19. //覆盖父类,不按id desc排序
  20. protected static function booted() { }
  21. public static function selectOptions(\Closure $closure = null)
  22. {
  23. $options = (new static())->withQuery($closure)->buildSelectOptions();
  24. return collect($options)->all();
  25. }
  26. }