'integer', 'is_active' => 'boolean', ]; } /** * Scope to filter active working hours. */ 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 */ 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; } }