<?php
namespace Hilco\Models;

use DB;

class DatafeedFieldTransformation extends WebModel {
    protected $table = 'DatafeedFieldTransformations';

    public function datafeedfield_datafeed()
    {
        return $this->belongsTo(DatafeedField_Datafeed::class, 'datafeedfield_datafeed_id', 'id');
    }
    
    public function transform($data) {
        if ($this->type === 'replace') {
            if ($data == $this->input) {
                return $this->output;
            } else {
                return $data;
            }
        }
    }
}
