<?php

namespace App\Models\Objects\Values;

class StringValue extends Value {
    protected $table = 'field_string_values';

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

    public static function applyFilter($query, $value) {
        collect(explode(' ', trim($value)))->each(function($term) use($query) {
            $query->where('value', 'like', "%{$term}%");
        });
    }
}