1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App; |
4
|
|
|
|
5
|
|
|
use Carbon\Carbon; |
6
|
|
|
use App\City; |
7
|
|
|
use Illuminate\Notifications\Notifiable; |
8
|
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail; |
9
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable; |
10
|
|
|
|
11
|
|
|
class Doctor extends Authenticatable |
12
|
|
|
{ |
13
|
|
|
use Notifiable; |
|
|
|
|
14
|
|
|
|
15
|
|
|
protected $guard = 'doctor'; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* The attributes that are mass assignable. |
19
|
|
|
* |
20
|
|
|
* @var array |
21
|
|
|
*/ |
22
|
|
|
protected $fillable = [ |
23
|
|
|
'name', 'biography', 'profile_picture', 'email', 'password' |
24
|
|
|
]; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* The attributes that should be hidden for arrays. |
28
|
|
|
* |
29
|
|
|
* @var array |
30
|
|
|
*/ |
31
|
|
|
protected $hidden = [ |
32
|
|
|
'password', 'remember_token', |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* The attributes that should be cast to native types. |
37
|
|
|
* |
38
|
|
|
* @var array |
39
|
|
|
*/ |
40
|
|
|
protected $casts = [ |
41
|
|
|
'email_verified_at' => 'datetime', |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var array |
46
|
|
|
*/ |
47
|
|
|
protected $dates = [ |
48
|
|
|
'created_at', |
49
|
|
|
'updated_at' |
50
|
|
|
]; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany |
54
|
|
|
*/ |
55
|
|
|
public function article() |
56
|
|
|
{ |
57
|
|
|
return $this->hasMany('App\Articles'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany |
62
|
|
|
*/ |
63
|
|
|
public function detail() |
64
|
|
|
{ |
65
|
|
|
return $this->hasMany('App\DoctorDetail'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
70
|
|
|
*/ |
71
|
|
|
public function specialty() |
72
|
|
|
{ |
73
|
|
|
return $this->belongsTo('App\DoctorSpecialization', 'specialization_id'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param $str |
78
|
|
|
* @return string |
79
|
|
|
*/ |
80
|
|
|
public function trimStr($str) |
81
|
|
|
{ |
82
|
|
|
if(strlen($str) > 20) { |
83
|
|
|
return substr($str, 0, 20)."..."; |
84
|
|
|
} |
85
|
|
|
return $str; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return string |
90
|
|
|
*/ |
91
|
|
|
public function getGreetings() |
92
|
|
|
{ |
93
|
|
|
$h = Carbon::now()->format('H'); |
94
|
|
|
|
95
|
|
|
if ($h >= 0 && $h < 6) { |
96
|
|
|
return "<i class='fa far fa-surprise fa-2x'></i> Wow, ini masih pagi loh "; |
97
|
|
|
} elseif ($h >= 6 && $h < 11) { |
98
|
|
|
return "<i class='fa far fa-laugh-beam fa-2x'></i> Selamat pagi "; |
99
|
|
|
} elseif ($h >= 11 && $h <= 14) { |
100
|
|
|
return "<i class='fa far fa-smile-wink fa-2x'></i> Selamat siang "; |
101
|
|
|
} elseif ($h > 14 && $h <= 16) { |
102
|
|
|
return "<i class='fa far fa-smile-beam fa-2x'></i> Selamat sore "; |
103
|
|
|
} elseif ($h >= 17 && $h < 20) { |
104
|
|
|
return "<i class='fa far fa-grin-stars fa-2x'></i> Senja yang indah ya "; |
105
|
|
|
} else { |
106
|
|
|
return "<i class='fa far fa-bed fa-2x'></i> Sudah malam, sebaiknya kamu istirahat "; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getLocation() |
111
|
|
|
{ |
112
|
|
|
$locationId = $this->getAttributeValue('city_id'); |
113
|
|
|
|
114
|
|
|
return $loc = City::find($locationId); |
|
|
|
|
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|