Passed
Push — dev5 ( de9a93...e80f59 )
by Ron
06:19
created

CustomerContactPhones   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 28
ccs 0
cts 8
cp 0
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTypeNameAttribute() 0 3 1
A PhoneNumberTypes() 0 3 1
A getReadableAttribute() 0 3 1
A getTypeIconAttribute() 0 3 1
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class CustomerContactPhones extends Model
8
{
9
    protected $fillable = ['cont_id', 'phone_type_id', 'phone_number', 'extension'];
10
    protected $appends = ['type_icon', 'type_name', 'readable'];
11
12
    // public function CustomerContacts()
13
    // {
14
    //     return $this->hasMany('App\CustomerContacts', 'cont_id', 'cont_id');
15
    // }
16
17
    public function getTypeIconAttribute()
18
    {
19
        return PhoneNumberTypes::find($this->phone_type_id)->icon_class;
20
    }
21
22
    public function getTypeNameAttribute()
23
    {
24
        return PhoneNumberTypes::find($this->phone_type_id)->description;
25
    }
26
27
    public function getReadableAttribute()
28
    {
29
        return PhoneNumberTypes::readablePhoneNumber($this->phone_number);
30
    }
31
32
    public function PhoneNumberTypes()
33
    {
34
        return $this->hasOne('App\PhoneNumberTypes', 'phone_type_id', 'phone_type_id');
35
    }
36
}
37