QwCategory.php 662 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Model\qw;
  3. use Illuminate\Database\Eloquent\Model;
  4. class QwCategory extends Model
  5. {
  6. public $table = "jm_qw_category";
  7. protected $appends = [
  8. 'department_desc' , 'pid_text'
  9. ];
  10. public $timestamps = false;
  11. /**
  12. * 部门描述
  13. */
  14. public function getDepartmentDescAttribute()
  15. {
  16. $department = QwDepartment::find($this->department_id);
  17. return $department->department_name ?? '';
  18. }
  19. /**
  20. * 父级分类
  21. */
  22. public function getPidTextAttribute()
  23. {
  24. $department = QwCategory::find($this->pid);
  25. return $department->category_name ?? '';
  26. }
  27. }