<?php

namespace App\Models\Objects\Values;

use Carbon\Carbon;

class TimeValue extends Value {
    protected $table = 'field_time_values';

    protected $dates = [
        'value',
        'ord'
    ];

    public function get() {
        return $this->value ? $this->value->toIso8601String() : null;
    }
    public function set($value): bool {
        return parent::set($value);
    }

    public static function applyFilter($query, $value) {
        $value = collect($value)->map(function($value) {
            return $value ? Carbon::create($value)->format('H:i:s') : null;
        });
        parent::applyFilter($query, $value->all());
    }

}