Passed
Push — develop ( 728d57...c3bbc8 )
by Septianata
05:08
created

Attribute::getGoogleMapUrlAttribute()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3.1406

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 7
ccs 3
cts 4
cp 0.75
rs 10
cc 3
nc 2
nop 0
crap 3.1406
1
<?php
2
3
namespace App\Models\Concerns\Customer;
4
5
use Illuminate\Support\Facades\Storage;
6
7
/**
8
 * @property string $telegram_chat_id
9
 * @property string $username
10
 * @property string $fullname
11
 * @property \App\Enum\Gender $gender
12
 * @property string $email
13
 * @property string $phone_country
14
 * @property \Propaganistas\LaravelPhone\PhoneNumber $phone
15
 * @property string $whatsapp_phone_country
16
 * @property \Propaganistas\LaravelPhone\PhoneNumber $whatsapp_phone
17
 * @property string $account_number
18
 * @property string $identitycard_number
19
 * @property string $identitycard_image
20
 * @property float|null $location_latitude
21
 * @property float|null $location_longitude
22
 * @property-read string|null $google_map_url
23
 *
24
 * @see \App\Models\Customer
25
 */
26
trait Attribute
27
{
28
    /**
29
     * Return "identitycard_image" attribute value.
30
     *
31
     * @param  mixed  $value
32
     * @return string
33
     */
34 2
    public function getIdentitycardImageAttribute($value): string
35
    {
36 2
        if (is_null($value)) {
37 1
            return asset('img/stisla/avatar/avatar-1.png');
38
        }
39
40 1
        return Storage::url(static::IDENTITYCARD_IMAGE_PATH . '/' . $value);
0 ignored issues
show
Bug introduced by
The constant App\Models\Concerns\Cust...IDENTITYCARD_IMAGE_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
41
    }
42
43
    /**
44
     * Return "google_map_url" attribute value.
45
     *
46
     * @return string|null
47
     */
48 1
    public function getGoogleMapUrlAttribute(): ?string
49
    {
50 1
        if (!is_null($this->location_latitude) && !is_null($this->location_longitude)) {
51 1
            return google_map_url($this->location_latitude, $this->location_longitude);
52
        }
53
54
        return null;
55
    }
56
}
57