protected function fillTimeAttribute($attrName) { $attributes = Attributes::getAttributesFor(get_called_class()); if (!($attribute = $attributes->getAttribute($attrName))) { return false; } switch ($attribute->type()) { case 'datetime': case 'timestamp': $value = date('Y-m-d H:i:s'); break; case 'date': $value = date('Y-m-d'); break; case 'time': $value = date('H:i:s'); break; case 'year': $value = date('Y'); break; default: return false; } $this->setAttribute($attrName, $value); return true; }
public static function getAttributeSet() { static::initAttributeSet(); return Attributes::getAttributesFor(get_called_class()); }