Completed
Push — master ( 33fa22...fb5d13 )
by Faiq
28s
created

Doctor::city()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
The trait Illuminate\Notifications\Notifiable requires some properties which are not provided by App\Doctor: $email, $phone_number
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
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
71
     */
72
    public function specialty()
73
    {
74
        return $this->belongsTo('App\DoctorSpecialization', 'id');
75
    }
76
77
    public function city() {
78
        return $this->belongsTo('App\City', 'city_id');
79
    }
80
81
    /**
82
     * @param $str
83
     * @return string
84
     */
85
    public function trimStr($str)
86
    {
87
        if(strlen($str) > 20) {
88
            return substr($str, 0, 20)."...";
89
        }
90
        return $str;
91
    }
92
93
    /**
94
     * @return string
95
     */
96
    public function getGreetings()
97
    {
98
        $h = Carbon::now()->format('H');
99
100
        if ($h >= 0 && $h < 6) {
101
            return "<i class='fa far fa-surprise fa-2x'></i>&nbsp;&nbsp;Wow, ini masih pagi loh ";
102
        } elseif ($h >= 6 && $h < 11) {
103
            return "<i class='fa far fa-laugh-beam fa-2x'></i>&nbsp;&nbsp;Selamat pagi ";
104
        } elseif ($h >= 11 && $h <= 14) {
105
            return "<i class='fa far fa-smile-wink fa-2x'></i>&nbsp;&nbsp;Selamat siang ";
106
        } elseif ($h > 14 && $h <= 16) {
107
            return "<i class='fa far fa-smile-beam fa-2x'></i>&nbsp;&nbsp;Selamat sore ";
108
        } elseif ($h >= 17 && $h < 20) {
109
            return "<i class='fa far fa-grin-stars fa-2x'></i>&nbsp;&nbsp;Senja yang indah ya ";
110
        } else {
111
            return "<i class='fa far fa-bed fa-2x'></i>&nbsp;&nbsp;Sudah malam, sebaiknya kamu istirahat ";
112
        }
113
    }
114
115
    public function getSpecialty()
116
    {
117
        $specialtyId = $this->getAttributeValue('specialization_id');
118
119
        return $specialty = DoctorSpecialization::find($specialtyId);
0 ignored issues
show
Unused Code introduced by
The assignment to $specialty is dead and can be removed.
Loading history...
120
    }
121
122
    public function getLocation()
123
    {
124
        $locationId = $this->getAttributeValue('city_id');
125
126
        return $loc = City::find($locationId);
0 ignored issues
show
Unused Code introduced by
The assignment to $loc is dead and can be removed.
Loading history...
127
    }
128
}
129