Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       100.00%  | 
       14 / 14  | 
               | 
       100.00%  | 
       4 / 4  | 
       CRAP |         | 
       100.00%  | 
       1 / 1  | 
      
| ConversionDigest |         | 
       100.00%  | 
       14 / 14  | 
               | 
       100.00%  | 
       4 / 4  | 
       4 |         | 
       100.00%  | 
       1 / 1  | 
      
| status |         | 
       100.00%  | 
       1 / 1  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| campaign |         | 
       100.00%  | 
       1 / 1  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| customer |         | 
       100.00%  | 
       1 / 1  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| jsonSerialize |         | 
       100.00%  | 
       11 / 11  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| 1 | <?php | 
| 2 | |
| 3 | namespace App\Models; | 
| 4 | |
| 5 | use Illuminate\Database\Eloquent\Factories\HasFactory; | 
| 6 | use Illuminate\Database\Eloquent\Model; | 
| 7 | use Illuminate\Database\Eloquent\Relations\HasOne; | 
| 8 | use Illuminate\Database\Eloquent\Relations\HasMany; | 
| 9 | use Illuminate\Database\Eloquent\Relations\BelongsTo; | 
| 10 | use Illuminate\Database\Eloquent\Relations\BelongsToMany; | 
| 11 | use Illuminate\Database\Eloquent\Relations\HasOneThrough; | 
| 12 | |
| 13 | /** | 
| 14 | * App\Models\ConversionDigest | 
| 15 | * | 
| 16 | * @property String $fblid | 
| 17 | * @property hasOneThrough $customer | 
| 18 | * @property \Illuminate\Database\Eloquent\Relations\HasOneThrough $customer_descriptive_name | 
| 19 | * @property \Illuminate\Database\Eloquent\Relations\HasOneThrough $customer_descriptive_name | 
| 20 | */ | 
| 21 | class ConversionDigest extends Model | 
| 22 | { | 
| 23 | use HasFactory; | 
| 24 | |
| 25 | protected $table = "conversions"; | 
| 26 | |
| 27 | |
| 28 | /** | 
| 29 | * Status name relationship | 
| 30 | */ | 
| 31 | public function status():hasOne | 
| 32 | { | 
| 33 | return $this->hasOne('App\Models\ConversionStatus', 'id', 'status_id'); | 
| 34 | } | 
| 35 | |
| 36 | /** | 
| 37 | * Campaign relationship | 
| 38 | */ | 
| 39 | public function campaign():hasOne | 
| 40 | { | 
| 41 | return $this->hasOne('App\Models\GoogleAdsCampaign', 'campaign_id', 'cmpid'); | 
| 42 | } | 
| 43 | |
| 44 | /** | 
| 45 | * Customer relationship through campaign | 
| 46 | */ | 
| 47 | public function customer():hasOneThrough | 
| 48 | { | 
| 49 | return $this->hasOneThrough( | 
| 50 | 'App\Models\GoogleAdsCustomer', // destination model | 
| 51 | 'App\Models\GoogleAdsCampaign', // intermediate model pivot | 
| 52 | 'campaign_id', // intermediate table. key pointing to this model. | 
| 53 | 'customer_id', // pk on destination model | 
| 54 | 'cmpid', // pk on this model | 
| 55 | 'customer_id' // intermediate table. key pointing to destination mode. | 
| 56 | ); | 
| 57 | } | 
| 58 | |
| 59 | |
| 60 | /** | 
| 61 | * Serialization | 
| 62 | */ | 
| 63 | public function jsonSerialize() | 
| 64 | { | 
| 65 | return [ | 
| 66 | 'id' => $this->id, | 
| 67 | 'gclid' => $this->gclid, | 
| 68 | 'fblid' => $this->fblid, | 
| 69 | 'cmpid' => $this->cmpid, | 
| 70 | 'website_url' => $this->website_url, | 
| 71 | 'status' => $this->status->name, | 
| 72 | 'created_at' => $this->created_at, | 
| 73 | 'campaign_id' => @$this->campaign->campaign_id, | 
| 74 | 'campaign_name' => @$this->campaign->campaign_name, | 
| 75 | 'customer_id' => @$this->customer->customer_id, | 
| 76 | 'customer_descriptive_name' => @$this->customer->customer_descriptive_name, | 
| 77 | ]; | 
| 78 | } // jsonSerialize | 
| 79 | } |