123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- /**
- * Created by PhpStorm.
- * User: zilongs
- * Date: 20-10-4
- * Time: 下午7:11
- */
- namespace App\Models;
- class ServicePack extends BaseModel
- {
- protected $appends = ['label_texts', 'service_pack_protocol', 'service_agreement_protocol'];
- protected $table = 'service_packs';
- protected $casts = [
- 'label' => 'json',
- 'team_id' => 'json'
- ];
- public function getLabelTextsAttribute()
- {
- $data = [];
- if (!empty($this->label)) {
- $map = config('config.pack_label_map');
- foreach ($this->label as $k => $v) {
- $data[$k]['name'] = $map[$v]??'';
- }
- }
- return $data;
- }
- public function systemconfig(){
- return $this->hasOne(SystemConfig::class,'id','agreement_id');
- }
- public function getServicePackProtocolAttribute()
- {
- $data = '';
- if (!empty($this->agreement_id)) {
- $data = InsuranceAgreement::where('id', $this->agreement_id)->value('content');
- }
- return $data;
- }
- public function getServiceAgreementProtocolAttribute()
- {
- $data = '';
- if (!empty($this->service_agreement_id)) {
- $data = ServiceAgreement::where('id', $this->service_agreement_id)->value('content');
- }
- return $data;
- }
- public function insuranceagreement()
- {
- return $this->hasOne(InsuranceAgreement::class,'id','agreement_id');
- }
- public function serviceagreement()
- {
- return $this->hasOne(ServiceAgreement::class,'id','service_agreement_id');
- }
- }
|