ServicePack.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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', 'service_pack_protocol'];
  12. protected $table = 'service_packs';
  13. protected $casts = [
  14. 'label' => 'json',
  15. 'team_id' => 'json'
  16. ];
  17. public function getLabelTextsAttribute()
  18. {
  19. $data = [];
  20. if (!empty($this->label)) {
  21. $map = config('config.pack_label_map');
  22. foreach ($this->label as $k => $v) {
  23. $data[$k]['name'] = $map[$v]??'';
  24. }
  25. }
  26. return $data;
  27. }
  28. public function systemconfig(){
  29. return $this->hasOne(SystemConfig::class,'id','agreement_id');
  30. }
  31. public function getServicePackProtocolAttribute()
  32. {
  33. $data = '';
  34. if (!empty($this->agreement_id)) {
  35. $data = InsuranceAgreement::where('id', $this->agreement_id)->value('content');
  36. }
  37. return $data;
  38. }
  39. public function insuranceagreement(){
  40. return $this->hasOne(InsuranceAgreement::class,'id','agreement_id');
  41. }
  42. public function serviceagreement(){
  43. return $this->hasOne(ServiceAgreement::class,'id','service_agreement_id');
  44. }
  45. }