complete 3.1 with qa test and future recommendations files also update claude md with init and laravel boost
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -27,8 +29,41 @@ class WorkingHour extends Model
|
||||
/**
|
||||
* Scope to filter active working hours.
|
||||
*/
|
||||
public function scopeActive($query)
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_active', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the day name for a given day of week.
|
||||
*/
|
||||
public static function getDayName(int $dayOfWeek, ?string $locale = null): string
|
||||
{
|
||||
$locale = $locale ?? app()->getLocale();
|
||||
$days = [
|
||||
'en' => ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
||||
'ar' => ['الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
];
|
||||
|
||||
return $days[$locale][$dayOfWeek] ?? $days['en'][$dayOfWeek];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available time slots for this working hour.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getSlots(int $duration = 60): array
|
||||
{
|
||||
$slots = [];
|
||||
$start = Carbon::parse($this->start_time);
|
||||
$end = Carbon::parse($this->end_time);
|
||||
|
||||
while ($start->copy()->addMinutes($duration)->lte($end)) {
|
||||
$slots[] = $start->format('H:i');
|
||||
$start->addMinutes($duration);
|
||||
}
|
||||
|
||||
return $slots;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user