/**
  * @param Schema $schema
  * @param string $resRelationshipName
  */
 private function getBelongToManyRelationshipModelClass(Schema $schema, $resRelationshipName)
 {
     list($relSchemaType) = $schema->getBelongsToManyRelationshipsMap()[$resRelationshipName];
     $relSchema = $this->getSchemaContainer()->getSchemaByResourceType($relSchemaType);
     $modelClass = $relSchema::MODEL;
     return $modelClass;
 }
 /**
  * @param FactoryInterface   $factory
  * @param ContainerInterface $container
  */
 public function __construct(FactoryInterface $factory, ContainerInterface $container)
 {
     parent::__construct($factory, $container);
     $this->addReadOnly([self::ATTR_CREATED_AT, self::ATTR_UPDATED_AT, self::ATTR_DELETED_AT]);
 }
 /**
  * @param array           $data
  * @param array           $rules
  * @param Schema          $schema
  * @param ErrorCollection $errors
  */
 protected function validateBelongsToRelationships(array $data, array $rules, Schema $schema, ErrorCollection $errors)
 {
     $validator = $this->createValidator($data, $rules);
     if ($validator->fails() === true) {
         $map = $schema->getModelBelongsToRelationshipsToResourceMap();
         $errors->addRelationshipErrorsFromMessageBag($validator->messages(), $map);
     }
 }