-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScheduleDay.php
96 lines (85 loc) · 3.29 KB
/
ScheduleDay.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* App\Models\ScheduleDay
*
* @property int $id
* @property int $doctor_id
* @property string $per_patient_time
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Doctor $doctor
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay whereDoctorId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay wherePerPatientTime($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay whereSerialVisibility($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay whereUpdatedAt($value)
*
* @mixin \Eloquent
*
* @property int $schedule_id
* @property string $available_on
* @property string $available_from
* @property string $available_to
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay whereAvailableFrom($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay whereAvailableOn($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay whereAvailableTo($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ScheduleDay whereScheduleId($value)
*
* @property-read Schedule $schedule
*/
class ScheduleDay extends Model
{
public static $rules = [
'doctor_id' => 'required',
'available_on' => 'required',
'available_from' => 'required',
'available_to' => 'required',
];
public $table = 'schedule_days';
public $fillable = [
'doctor_id',
'schedule_id',
'available_on',
'available_from',
'available_to',
];
protected $casts = [
'id' => 'integer',
'doctor_id' => 'integer',
'schedule_id' => 'integer',
'available_on' => 'string',
];
public function getAvailableFromAttribute()
{
return \Carbon\Carbon::parse($this->attributes['available_from'])->Format('H:i:s');
}
public function getAvailableToAttribute()
{
return \Carbon\Carbon::parse($this->attributes['available_to'])->Format('H:i:s');
}
public function doctor(): BelongsTo
{
return $this->belongsTo(Doctor::class, 'doctor_id');
}
public function schedule(): BelongsTo
{
return $this->belongsTo(Schedule::class, 'schedule_id');
}
public function prepareScheduleDay()
{
return [
'available_on' => $this->available_on ?? __('messages.common.n/a'),
'available_from' => $this->available_from ?? __('messages.common.n/a'),
'available_to' => $this->available_to ?? __('messages.common.n/a'),
];
}
}