protected function embedsOne(string $entity, string $field)
    {
        if (is_subclass_of($entity, Schema::class)) {
            $entity = (new $entity())->entityClass;
        }

        $items = (array) $this->$field;
        if (false === empty($items) && false === array_key_exists(0, $items)) {
            $items = [$items];
        }

        return Ioc::make(CursorFactory::class)
            ->createEmbeddedCursor($entity, $items)->first();
    }
protected function embedsOne(string $entity, string $field)
    {
        if (is_subclass_of($entity, Schema::class)) {
            $entity = (new $entity())->entityClass;
        }

        $items = (array) $this->$field;
        if (false === empty($items) && false === array_key_exists(0, $items)) {
            $items = [$items];
        }

        return Ioc::make(CursorFactory::class)
            ->createEmbeddedCursor($entity, $items)->first();
    }
protected function embedsOne ( string $ entity , string $ field ) { if ( is_subclass_of ( $ entity , Schema :: class ) ) { $ entity = ( new $ entity ( ) ) -> entityClass ; } $ items = ( array ) $ this -> $ field ; if ( false === empty ( $ items ) && false === array_key_exists ( 0 , $ items ) ) { $ items = [ $ items ] ; } return Ioc :: make ( CursorFactory :: class ) -> createEmbeddedCursor ( $ entity , $ items ) -> first ( ) ; }
Return a embedded documents as object.

@param string $entity class of the entity or of the schema of the entity
@param string $field  field where the embedded document is stored

@return Model|null
Return a embedded documents as object .