Passed
Push — master ( 532256...bd524b )
by Faiq
07:50 queued 03:38
created

Doctor::getLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
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', 'specialization_id');
75
    }
76
77
    public function city() {
78
        return $this->belongsTo('App\City', 'city_id');
79
    }
80
81
    public function thread() {
82
        return $this->hasMany('App\Thread', 'doctor_id');
83
    }
84
85
    /**
86
     * @param $str
87
     * @return string
88
     */
89
    public function trimStr($str)
90
    {
91
        if(strlen($str) > 20) {
92
            return substr($str, 0, 20)."...";
93
        }
94
        return $str;
95
    }
96
97
    /**
98
     * @return string
99
     */
100
    public function getGreetings()
101
    {
102
        $h = Carbon::now()->format('H');
103
104
        if ($h >= 0 && $h < 6) {
105
            return "<i class='fa far fa-surprise fa-2x'></i>&nbsp;&nbsp;Wow, ini masih pagi loh ";
106
        } elseif ($h >= 6 && $h < 11) {
107
            return "<i class='fa far fa-laugh-beam fa-2x'></i>&nbsp;&nbsp;Selamat pagi ";
108
        } elseif ($h >= 11 && $h <= 14) {
109
            return "<i class='fa far fa-smile-wink fa-2x'></i>&nbsp;&nbsp;Selamat siang ";
110
        } elseif ($h > 14 && $h <= 16) {
111
            return "<i class='fa far fa-smile-beam fa-2x'></i>&nbsp;&nbsp;Selamat sore ";
112
        } elseif ($h >= 17 && $h < 20) {
113
            return "<i class='fa far fa-grin-stars fa-2x'></i>&nbsp;&nbsp;Senja yang indah ya ";
114
        } else {
115
            return "<i class='fa far fa-bed fa-2x'></i>&nbsp;&nbsp;Sudah malam, sebaiknya kamu istirahat ";
116
        }
117
    }
118
119
    /**
120
     * @return mixed
121
     */
122
    public function getSpecialty()
123
    {
124
        $specialtyId = $this->getAttributeValue('specialization_id');
125
126
        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...
127
    }
128
129
    /**
130
     * @return mixed
131
     */
132
    public function getLocation()
133
    {
134
        $locationId = $this->getAttributeValue('city_id');
135
136
        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...
137
    }
138
}
139