Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
48 / 48
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
Conversion
100.00% covered (success)
100.00%
48 / 48
100.00% covered (success)
100.00%
5 / 5
6
100.00% covered (success)
100.00%
1 / 1
 status
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 statusUser
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 currency
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 notes
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 jsonSerialize
100.00% covered (success)
100.00%
44 / 44
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Factories\HasFactory;
6use Illuminate\Database\Eloquent\Model;
7use Illuminate\Database\Eloquent\Relations\HasOne;
8use Illuminate\Database\Eloquent\Relations\HasMany;
9use Illuminate\Database\Eloquent\Relations\BelongsTo;
10use Illuminate\Database\Eloquent\Relations\BelongsToMany;
11
12class Conversion extends Model
13{
14    use HasFactory;
15
16    protected $table = "conversions";
17
18    /**
19     * Status name relationship
20     */
21    public function status():HasOne
22    {
23        return $this->hasOne('App\Models\ConversionStatus', 'id', 'status_id');
24    }
25
26    /**
27     * Status name relationship
28     */
29    public function statusUser():HasOne
30    {
31        return $this->hasOne('App\Models\User', 'id', 'status_user_id');
32    }
33
34    /**
35     * Currency relationship
36     */
37    public function currency():HasOne
38    {
39        return $this->hasOne('App\Models\ConversionCurrency', 'id', 'conversion_currency');
40    }
41
42    /**
43     * ConversionNotes relationship
44     *
45     * @return HasMany
46     */
47    protected function notes():HasMany
48    {
49        return $this->hasMany('App\Models\ConversionNote', 'conversion_id', 'id')->orderBy('id', 'desc');
50    }
51
52
53    /**
54     * Serialization
55     */
56    public function jsonSerialize()
57    {
58        $statusUser = null;
59        if ($this->status->id) {
60            $statusUser = $this->statusUser;
61        }
62
63        return [
64            'id' => $this->id,
65            'gclid' => $this->gclid,
66            'fbclid' => $this->fbclid,
67            'event_category' => $this->event_category,
68            'event_action' => $this->event_action,
69            'event_label' => $this->event_label,
70            'website_url' => $this->website_url,
71            'utm_campaign_id' => $this->utm_campaign_id,
72            'utm_campaign_source' => $this->utm_campaign_source,
73            'utm_campaign_medium' => $this->utm_campaign_medium,
74            'utm_campaign_name' => $this->utm_campaign_name,
75            'utm_campaign_term' => $this->utm_campaign_term,
76            'utm_campaign_content' => $this->utm_campaign_content,
77            'conversion_name' => $this->conversion_name,
78            'conversion_time' => $this->conversion_time,
79            'conversion_value' => $this->conversion_value,
80            'conversion_currency' => $this->currency->name,
81            //'conversion_state' => $this->conversion_state,
82            'nw' => $this->nw,
83            'cmpid' => $this->cmpid,
84            'agid' => $this->agid,
85            'fiid' => $this->fiid,
86            'tgid' => $this->tgid,
87            'loc' => $this->loc,
88            'ploc' => $this->ploc,
89            'match' => $this->match,
90            'dev' => $this->dev,
91            'devm' => $this->devm,
92            'cmpt' => $this->cmpt,
93            'ad' => $this->ad,
94            'pl' => $this->pl,
95            'pltar' => $this->pltar,
96            'pr1' => $this->pr1,
97            'pr2' => $this->pr2,
98            'url' => $this->url,
99            'adpos' => $this->adpos,
100            'mobile' => (bool)$this->mobile,
101            'approved_datetime' => $this->approved_datetime,
102            'created_at' => $this->created_at,
103            'updated_at' => $this->updated_at,
104            'status' => $this->status->name,
105            'status_user' => $statusUser,
106            'notes' => $this->notes,
107        ];
108    } // jsonSerialize
109}