Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
62.50% covered (warning)
62.50%
5 / 8
62.50% covered (warning)
62.50%
5 / 8
CRAP
0.00% covered (danger)
0.00%
0 / 1
Client
62.50% covered (warning)
62.50%
5 / 8
62.50% covered (warning)
62.50%
5 / 8
11.38
0.00% covered (danger)
0.00%
0 / 1
 clientType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 segment
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 strategyType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 administrator
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 commercials
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 tickets
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 files
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 gestionaRawResponses
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Factories\HasFactory;
6use Illuminate\Database\Eloquent\Model;
7
8class Client extends Model
9{
10    use HasFactory;
11
12    public const TYPE_ADMINISTRADOR = 1;
13
14    public const TYPE_GRAN_CLIENTE = 2;
15
16    public const TYPE_FACILITIES = 3;
17
18    public const TYPE_GENERAL = 4;
19
20    public const TYPE_LEAD = 5;
21
22    protected $table = 'tbl_clients';
23
24    protected $fillable = [
25        'client_type_id',
26        'company_name',
27        'fiscal_id',
28        'address',
29        'postal_code',
30        'city',
31        'province',
32        'segment_id',
33        'strategy_type_id',
34        'scope',
35        'region',
36        'administrator_id',
37        'annual_maintenance',
38        'annual_maint_start_date',
39        'annual_maint_frequency',
40        'quarterly_maintenance',
41        'quarterly_maint_start_date',
42        'quarterly_maint_frequency',
43        'contract_end_date',
44        'last_work_date',
45        'fire_suppression',
46        'fire_detection',
47        'water',
48        'relationship_status',
49        'termination_date',
50        'non_client_contract_end_date',
51        'payment_method',
52        'client_annual_billing',
53        'fire_current_billing',
54        'fire_billing_potential',
55        'contact_name',
56        'contact_phone',
57        'contact_email',
58        'notes',
59        'gestiona_client_code',
60        'associated_billing_client',
61        'allows_communications',
62        'last_visit_date',
63    ];
64
65    protected $casts = [
66        'annual_maintenance' => 'boolean',
67        'quarterly_maintenance' => 'boolean',
68        'fire_suppression' => 'boolean',
69        'fire_detection' => 'boolean',
70        'water' => 'boolean',
71        'allows_communications' => 'boolean',
72        'client_annual_billing' => 'decimal:2',
73        'fire_current_billing' => 'decimal:2',
74        'fire_billing_potential' => 'decimal:2',
75        'annual_maint_start_date' => 'date',
76        'quarterly_maint_start_date' => 'date',
77        'contract_end_date' => 'date',
78        'last_work_date' => 'date',
79        'termination_date' => 'date',
80        'non_client_contract_end_date' => 'date',
81        'last_visit_date' => 'date',
82    ];
83
84    public function clientType()
85    {
86        return $this->belongsTo(ClientType::class, 'client_type_id');
87    }
88
89    public function segment()
90    {
91        return $this->belongsTo(TblSegments::class, 'segment_id', 'segment_id');
92    }
93
94    public function strategyType()
95    {
96        return $this->belongsTo(StrategyType::class, 'strategy_type_id');
97    }
98
99    public function administrator()
100    {
101        return $this->belongsTo(Administrator::class, 'administrator_id');
102    }
103
104    public function commercials()
105    {
106        return $this->belongsToMany(TblUsers::class, 'tbl_client_commercial', 'client_id', 'user_id');
107    }
108
109    public function tickets()
110    {
111        return $this->hasMany(ClientTicket::class, 'client_id');
112    }
113
114    public function files()
115    {
116        return $this->hasMany(TblClientFile::class, 'client_id');
117    }
118
119    public function gestionaRawResponses()
120    {
121        return $this->hasMany(ClientGestionaResponse::class, 'client_id');
122    }
123}