Exemplo n.º 1
0
 /**
  * @param Validator $validator
  * @return ResourceDefinitionManipulator
  */
 public function validator(Validator $validator) : ResourceDefinitionManipulator
 {
     return $this->resourceDefinition->validator($validator);
 }
 public function __construct()
 {
     parent::__construct(User::class);
     $this->identifier('id')->int()->field('name')->required()->visible(true)->writeable()->field('email')->visible(true);
 }
 /**
  * CategoryDefinition constructor.
  */
 public function __construct()
 {
     parent::__construct(Category::class);
     $this->identifier('id')->int()->field('name')->string()->required()->visible(true, true)->field('description')->display('category-description')->visible();
 }
 /**
  * OrderResourceDefinition constructor.
  */
 public function __construct()
 {
     parent::__construct(Order::class);
     $this->identifier('id')->int()->field('complete')->bool()->relationship('pet', PetResourceDefinition::class)->one()->required()->linkable()->field('quantity')->int()->field('shipDate')->datetime()->field('status')->enum(['placed', 'approved', 'delivered']);
 }
 /**
  * PhotoDefinition constructor.
  */
 public function __construct()
 {
     parent::__construct(Photo::class);
     $this->identifier('id')->display('photo-id')->field('url')->visible(true, true)->writeable();
 }
 /**
  * TagDefinition constructor.
  */
 public function __construct()
 {
     parent::__construct(Tag::class);
     $this->identifier('id')->int()->display('tag-id')->field('name')->required()->visible(true, true);
 }
 public function __construct()
 {
     parent::__construct(Pet::class);
     $this->identifier('id')->int()->field('name')->writeable()->required()->visible(true)->relationship('category', CategoryResourceDefinition::class)->one()->visible()->expandable()->expanded()->linkable()->relationship('photos', PhotoResourceDefinition::class)->many()->visible()->expandable()->expanded()->writeable()->records(3)->url('api/v1/pets/{model.id}/photos')->relationship('tags', TagResourceDefinition::class)->many()->linkable()->expandable()->expanded()->visible()->field('status')->enum([Pet::STATUS_AVAILABLE, Pet::STATUS_ENDING, Pet::STATUS_SOLD])->visible()->validator(new PetValidator());
 }