Category.php 734 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\admin\model\shopro;
  3. use app\admin\model\shopro\Common;
  4. class Category extends Common
  5. {
  6. protected $name = 'shopro_category';
  7. // 追加属性
  8. protected $append = [
  9. 'status_text',
  10. ];
  11. public function getChildrenString($category)
  12. {
  13. $style = $category->style;
  14. $string = 'children';
  15. if (strpos($style, 'second') === 0) {
  16. $string .= '.children';
  17. } else if (strpos($style, 'third') === 0) {
  18. $string .= '.children.children';
  19. }
  20. return $string;
  21. }
  22. public function children()
  23. {
  24. return $this->hasMany(self::class, 'parent_id', 'id')->normal()->order('weigh', 'desc')->order('id', 'asc');
  25. }
  26. }