<?php

namespace RadiusTheme\RadiusBooking\Models;

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

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

	/**
	 * The attributes that are mass assignable.
	 *
	 * @var array
	 */
	protected array $fillable = array(
		'user_id',
		'day_index',
		'start_time',
		'end_time',
	);
	/**
	 * The attributes that should be cast to native types.
	 *
	 * @var array
	 */
	protected array $casts = array(
		'day_index'  => 'integer',
		'start_time' => 'datetime',
		'end_time'   => 'datetime',
	);

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

	/**
	 * Get the time periods associated with the employee for a specific weekday.
	 */
	public function employeeTimePeriods() {
		return $this->hasMany( EmployeeWeekdayTimePeriod::class, 'weekday_id', 'id' );
	}

	/**
	 * Get the break times associated with the employee for a specific weekday.
	 */
	public function employeeBreakTimes() {
		return $this->hasMany( EmployeeWeekdayBreakTime::class, 'weekday_id', 'id' );
	}

	/**
	 * Retrieve the ID attribute of the model.
	 *
	 * @return int|string The ID of the model.
	 */
	public function get_id() {
		return $this->attributes['id'];
	}
}
