<?php

/**
 * Created by JSM, based on Reliese Model.
 * Date: {{date}}.
 */

namespace {{namespace}};

use {{parent}};

/**
 * Class {{class}}
 * {{properties}}
 *
 * @package {{namespace}}
 */
class {{class}} extends {{parent}}
{

    public function __construct(array $attributes = array()){
        parent::__construct($attributes);

        //andiamo ad impostare nel modello le regole a partire dai vincoli del DB (lunghezza e tipo)
        if(isset($this->db_rules) && is_array($this->db_rules)){

            // supporto legacy per le rules eventualmente definite nell'array della classe estesa
            $rules_modello_esteso = is_array($this->rules) ? $this->rules : [];

            foreach($rules_modello_esteso as $key => $value){
                if(isset($this->db_rules[$key])){
                    $rules_modello_esteso[$key] .= "|".$this->db_rules[$key];
                }
            }

            $this->rules = array_merge($this->db_rules, $rules_modello_esteso);
        }
    }

{{body}}
}
