1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Models\Concerns\Customer; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Storage; |
6
|
|
|
use Illuminate\Support\Str; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @property string $telegram_chat_id |
10
|
|
|
* @property string $username |
11
|
|
|
* @property string $fullname |
12
|
|
|
* @property \App\Enum\Gender $gender |
13
|
|
|
* @property string $email |
14
|
|
|
* @property string $phone_country |
15
|
|
|
* @property \Propaganistas\LaravelPhone\PhoneNumber $phone |
16
|
|
|
* @property string $whatsapp_phone_country |
17
|
|
|
* @property \Propaganistas\LaravelPhone\PhoneNumber $whatsapp_phone |
18
|
|
|
* @property string|null $account_number |
19
|
|
|
* @property string|null $identitycard_number |
20
|
|
|
* @property string|null $identitycard_image |
21
|
|
|
* @property float|null $location_latitude |
22
|
|
|
* @property float|null $location_longitude |
23
|
|
|
* @property-read string|null $google_map_url |
24
|
|
|
* @property-read string $whatsapp_phone_url |
25
|
|
|
* |
26
|
|
|
* @see \App\Models\Customer |
27
|
|
|
*/ |
28
|
|
|
trait Attribute |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Return "identitycard_image" attribute value. |
32
|
|
|
* |
33
|
|
|
* @param mixed $value |
34
|
|
|
* @return string|null |
35
|
|
|
*/ |
36
|
2 |
|
public function getIdentitycardImageAttribute($value): ?string |
37
|
|
|
{ |
38
|
2 |
|
if (is_null($value)) { |
39
|
1 |
|
return null; |
40
|
|
|
} |
41
|
|
|
|
42
|
1 |
|
return Storage::url(static::IDENTITYCARD_IMAGE_PATH . '/' . $value); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Return "google_map_url" attribute value. |
47
|
|
|
* |
48
|
|
|
* @return string|null |
49
|
|
|
*/ |
50
|
1 |
|
public function getGoogleMapUrlAttribute(): ?string |
51
|
|
|
{ |
52
|
1 |
|
if (!is_null($this->location_latitude) && !is_null($this->location_longitude)) { |
53
|
1 |
|
return google_map_url($this->location_latitude, $this->location_longitude); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return null; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Return "whatsapp_phone_url" attribute value. |
61
|
|
|
* |
62
|
|
|
* @return string |
63
|
|
|
*/ |
64
|
|
|
public function getWhatsappPhoneUrlAttribute(): string |
65
|
|
|
{ |
66
|
|
|
return 'https://wa.me/' . Str::replaceFirst('+', '', $this->whatsapp_phone->formatE164()); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|