/** * @param $data * * @return array */ public function toRepresentation($data) { $values = []; foreach ($data as $item) { $values[] = $this->child->toRepresentation($item); } return $values; }
/** * @param Serializer $serializer */ public function performStore(Serializer $serializer) { $serializer->save(); }
/** * @param $data * * Return [isEmpty, data] * * @return array * @throws SkipField * @throws ValidationError */ public function validateEmptyValues($data) { if ($this->readOnly) { return [true, $this->getDefault()]; } if (EmptyType::isEmpty($data)) { if ($this->root instanceof Serializer and $this->root->partial()) { throw new SkipField(); } if ($this->required) { $this->fail('required'); } return [true, $this->getDefault()]; } if ($data === null) { if (!$this->allowNull) { $this->fail('invalid'); } return [true, null]; } return [false, $data]; }
/** * @param Serializer $serializer */ public function performUpdate(Serializer $serializer) { $serializer->save(); }