feat: add shift management functionality
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Shift extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'day_of_week',
|
||||
'date',
|
||||
'start_time',
|
||||
'end_time',
|
||||
'is_active',
|
||||
'user_id',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date' => 'date',
|
||||
'is_active' => 'boolean',
|
||||
'user_id' => 'integer',
|
||||
'created_by' => 'integer',
|
||||
];
|
||||
|
||||
public function doctor()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('is_active', true);
|
||||
}
|
||||
|
||||
public function scopeOpen($query)
|
||||
{
|
||||
return $query->whereNull('user_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user