ServicePack.php 726 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: zilongs
  5. * Date: 20-10-4
  6. * Time: 下午7:11
  7. */
  8. namespace App\Models;
  9. class ServicePack extends BaseModel
  10. {
  11. protected $appends = ['label_texts'];
  12. protected $table = 'service_packs';
  13. protected $casts = [
  14. 'label' => 'json',
  15. 'team_id' => 'json'
  16. ];
  17. public function team()
  18. {
  19. return $this->belongsToMany(Team::class);
  20. }
  21. public function getLabelTextsAttribute()
  22. {
  23. $data = [];
  24. if (!empty($this->label)) {
  25. $map = config('config.pack_label_map');
  26. foreach ($this->label as $k => $v) {
  27. $data[$k]['name'] = $map[$v]??'';
  28. }
  29. }
  30. return $data;
  31. }
  32. }