<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class DeviceSchedule extends Model
{
    protected $connection = 'mai2';

    protected $fillable = [
        'device_id', 'name', 'plan_template_no', 'week_plan_no',
        'begin_time', 'end_time', 'days',
        'is_synced', 'last_synced_at', 'last_error',
    ];

    protected $casts = [
        'begin_time' => 'datetime',
        'end_time' => 'datetime',
        'days' => 'array',
        'last_synced_at' => 'datetime',
    ];

    public function device()
    {
        return $this->belongsTo(Device::class);
    }

    public const ALL_DAYS = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'];
}