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