<?php

namespace RadiusTheme\RadiusBooking\Models;

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

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

	/**
	 * The attributes that are mass assignable.
	 *
	 * @var array
	 */
	protected array $fillable = array(
		'name',
		'status',
		'order_number',
		'image_id',
		'translations',
	);

	/**
	 * The validation rules.
	 *
	 * @var array
	 */
	protected array $rules = array(
		'name' => 'required|string|max:255',
	);

	/**
	 * The attributes that should be cast to native types.
	 *
	 * @var array|string[]
	 */
	protected array $casts = array(
		'translations' => 'json',
	);

	/**
	 * Defines a relationship indicating that the current model can have many related Service models.
	 */
	public function services() {
		return $this->hasMany( Service::class, 'category_id', 'id' );
	}
}
