feat: add shift management functionality

This commit is contained in:
2026-08-26 18:53:15 +03:30
parent 2d96978c38
commit aeef95339d
34 changed files with 1953 additions and 15 deletions
+48
View File
@@ -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');
}
}
+5
View File
@@ -71,4 +71,9 @@ class User extends Authenticatable
{
return $this->hasMany(Pet::class, 'owner_id');
}
public function shifts()
{
return $this->hasMany(Shift::class);
}
}