2021-06-08 19:30:42 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
|
|
use Appwrite\Utopia\Response;
|
|
|
|
|
use Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
|
|
class Attribute extends Model
|
|
|
|
|
{
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
$this
|
2021-08-18 11:41:35 +00:00
|
|
|
->addRule('$collection', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Collection ID.',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => '5e5ea5c16d55',
|
|
|
|
|
])
|
2021-06-08 19:30:42 +00:00
|
|
|
->addRule('$id', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Attribute ID.',
|
|
|
|
|
'default' => '',
|
2021-06-30 18:49:54 +00:00
|
|
|
'example' => '60ccf71b98a2d',
|
2021-06-08 19:30:42 +00:00
|
|
|
])
|
|
|
|
|
->addRule('type', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Attribute type.',
|
|
|
|
|
'default' => '',
|
2021-07-05 18:28:38 +00:00
|
|
|
'example' => 'string',
|
2021-06-08 19:30:42 +00:00
|
|
|
])
|
|
|
|
|
->addRule('size', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Attribute size.',
|
|
|
|
|
'default' => 0,
|
2021-07-05 18:28:38 +00:00
|
|
|
'example' => 128,
|
2021-06-08 19:30:42 +00:00
|
|
|
])
|
|
|
|
|
->addRule('required', [
|
|
|
|
|
'type' => self::TYPE_BOOLEAN,
|
|
|
|
|
'description' => 'Is attribute required?',
|
|
|
|
|
'default' => false,
|
2021-07-05 18:28:38 +00:00
|
|
|
'example' => true,
|
2021-06-08 19:30:42 +00:00
|
|
|
])
|
|
|
|
|
->addRule('array', [
|
|
|
|
|
'type' => self::TYPE_BOOLEAN,
|
|
|
|
|
'description' => 'Is attribute an array?',
|
|
|
|
|
'default' => false,
|
|
|
|
|
'example' => false,
|
2021-06-09 21:10:19 +00:00
|
|
|
'required' => false
|
2021-06-08 19:30:42 +00:00
|
|
|
])
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Name
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getName():string
|
|
|
|
|
{
|
|
|
|
|
return 'Attribute';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Collection
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getType():string
|
|
|
|
|
{
|
|
|
|
|
return Response::MODEL_ATTRIBUTE;
|
|
|
|
|
}
|
|
|
|
|
}
|