vendredi 31 mars 2017

Type casting using string for type

I have table settings with columns: value - varchar type contains setting value and type - enum type contains variable types "int", "string", "float". How can I use string from type column to cast value to this type?

I'm trying to do it in my model but it doesn't work:

public function getValueAttribute($value){
    return ($this->type)$value;
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire