ServicePack.php 690 B

1234567891011121314151617181920212223242526272829303132333435
  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. ];
  16. public function team()
  17. {
  18. return $this->belongsTo(Team::class);
  19. }
  20. public function getLabelTextsAttribute()
  21. {
  22. $data = [];
  23. if (!empty($this->label)) {
  24. $map = config('config.pack_label_map');
  25. foreach ($this->label as $k => $v) {
  26. $data[$k]['name'] = $map[$v];
  27. }
  28. }
  29. return $data;
  30. }
  31. }