<?php

namespace RadiusTheme\RadiusBooking\Models;

use RadiusTheme\RadiusBooking\Abstracts\BaseModel;
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
/**
 * Class EmployeeWeekdayTimePeriod
 *
 * @package RadiusTheme\RadiusBooking\Models
 *
 * @property int    $id
 * @property string $name
 */
class EmployeeWeekdayTimePeriod extends BaseModel {

	/**
	 * The database table associated with the model.
	 *
	 * @var string
	 */
	protected string $table = 'radius_booking_emp_weekday_time_periods';

	/**
	 * The attributes that are mass assignable.
	 *
	 * @var array
	 */
	protected array $fillable = array(
		'weekday_id',
		'start_time',
		'end_time',
	);

	/**
	 * Get the weekday associated with the time period.
	 *
	 * @return \RadiusTheme\RadiusBooking\Core\ORM\Relations\HasOne
	 */
	public function weekday() {
		return $this->hasOne( EmployeeWeekday::class, 'id', 'weekday_id' );
	}

	/**
	 * Get the locations associated with the time period.
	 *
	 * @return \RadiusTheme\RadiusBooking\Core\ORM\Relations\HasMany
	 */
	public function locations() {
		return $this->hasMany( EmployeeWeekdayTimePeriodLocation::class, 'weekday_time_period_id', 'id' );
	}

	/**
	 * Get the services associated with the time period.
	 *
	 * @return \RadiusTheme\RadiusBooking\Core\ORM\Relations\HasMany
	 */
	public function services() {
		return $this->hasMany( EmployeeWeekdayTimePeriodService::class, 'weekday_time_period_id', 'id' );
	}

	/**
	 * Retrieve the ID attribute of the current instance.
	 *
	 * @return mixed The ID value if it exists, or null if not set.
	 */
	public function get_id() {
		return $this->attributes['id'] ?? null;
	}
}
