complete story 3.2 with qa tests

This commit is contained in:
Naser Mansour
2025-12-26 18:43:26 +02:00
parent e679a45933
commit 43df24c7cd
18 changed files with 1483 additions and 74 deletions
+44 -2
View File
@@ -2,6 +2,8 @@
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@@ -24,10 +26,50 @@ class BlockedTime extends Model
}
/**
* Check if this is a full day block.
* Check if this is a full day block (all-day event).
*/
public function isFullDay(): bool
public function isAllDay(): bool
{
return is_null($this->start_time) && is_null($this->end_time);
}
/**
* Scope to get upcoming blocked times (today and future).
*/
public function scopeUpcoming(Builder $query): Builder
{
return $query->where('block_date', '>=', today());
}
/**
* Scope to get past blocked times.
*/
public function scopePast(Builder $query): Builder
{
return $query->where('block_date', '<', today());
}
/**
* Scope to filter by a specific date.
*/
public function scopeForDate(Builder $query, $date): Builder
{
return $query->where('block_date', $date);
}
/**
* Check if this block covers a specific time slot.
*/
public function blocksSlot(string $time): bool
{
if ($this->isAllDay()) {
return true;
}
$slotTime = Carbon::parse($time);
$start = Carbon::parse($this->start_time);
$end = Carbon::parse($this->end_time);
return $slotTime->gte($start) && $slotTime->lt($end);
}
}