appwrite/src/Appwrite/Utopia/Response/Model/AttributeDatetime.php

69 lines
1.7 KiB
PHP
Raw Normal View History

2022-07-25 08:53:41 +00:00
<?php
namespace Appwrite\Utopia\Response\Model;
use Appwrite\Utopia\Response;
class AttributeDatetime extends Attribute
{
public function __construct()
{
parent::__construct();
$this
->addRule('key', [
'type' => self::TYPE_STRING,
'description' => 'Attribute Key.',
'default' => '',
'example' => 'birthDay',
])
->addRule('type', [
'type' => self::TYPE_DATETIME,
'description' => 'Attribute type.',
'default' => '',
2022-08-14 10:27:07 +00:00
'example' => self::TYPE_DATETIME_EXAMPLE,
2022-07-25 08:53:41 +00:00
])
->addRule('format', [
'type' => self::TYPE_DATETIME,
'description' => 'Datetime format.',
'default' => APP_DATABASE_ATTRIBUTE_DATETIME,
'example' => APP_DATABASE_ATTRIBUTE_DATETIME,
'array' => false,
'require' => true,
])
->addRule('default', [
'type' => self::TYPE_STRING,
'description' => 'Default value for attribute when not provided. Only null is optional',
'default' => null,
2022-08-14 10:27:07 +00:00
'example' => self::TYPE_DATETIME_EXAMPLE,
2022-07-25 08:53:41 +00:00
'array' => false,
'require' => false,
])
;
}
public array $conditions = [
2022-07-28 12:38:54 +00:00
'type' => self::TYPE_DATETIME
2022-07-25 08:53:41 +00:00
];
/**
* Get Name
*
* @return string
*/
public function getName(): string
{
return 'AttributeDatetime';
}
/**
* Get Type
*
* @return string
*/
public function getType(): string
{
return Response::MODEL_ATTRIBUTE_DATETIME;
}
}