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