Passed
Pull Request — master (#50)
by
unknown
04:43
created

Doctor::getSpecialty()   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
    /**
78
     * @param $str
79
     * @return string
80
     */
81
    public function trimStr($str)
82
    {
83
        if(strlen($str) > 20) {
84
            return substr($str, 0, 20)."...";
85
        }
86
        return $str;
87
    }
88
89
    /**
90
     * @return string
91
     */
92
    public function getGreetings()
93
    {
94
        $h = Carbon::now()->format('H');
95
96
        if ($h >= 0 && $h < 6) {
97
            return "<i class='fa far fa-surprise fa-2x'></i>&nbsp;&nbsp;Wow, ini masih pagi loh ";
98
        } elseif ($h >= 6 && $h < 11) {
99
            return "<i class='fa far fa-laugh-beam fa-2x'></i>&nbsp;&nbsp;Selamat pagi ";
100
        } elseif ($h >= 11 && $h <= 14) {
101
            return "<i class='fa far fa-smile-wink fa-2x'></i>&nbsp;&nbsp;Selamat siang ";
102
        } elseif ($h > 14 && $h <= 16) {
103
            return "<i class='fa far fa-smile-beam fa-2x'></i>&nbsp;&nbsp;Selamat sore ";
104
        } elseif ($h >= 17 && $h < 20) {
105
            return "<i class='fa far fa-grin-stars fa-2x'></i>&nbsp;&nbsp;Senja yang indah ya ";
106
        } else {
107
            return "<i class='fa far fa-bed fa-2x'></i>&nbsp;&nbsp;Sudah malam, sebaiknya kamu istirahat ";
108
        }
109
    }
110
111
    public function getSpecialty()
112
    {
113
        $specialtyId = $this->getAttributeValue('specialization_id');
114
115
        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...
116
    }
117
118
    public function getLocation()
119
    {
120
        $locationId = $this->getAttributeValue('city_id');
121
122
        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...
123
    }
124
}
125