sample/Application/EncodeSamples.php
public function getIncludedObjectsExample(): string
    {
        $author   = Author::instance('123', 'John', 'Dow');
        $comments = [
            Comment::instance('456', 'Included objects work as easy as basic ones', $author),
            Comment::instance('789', 'Let\'s try!', $author),
        ];
        $post     = Post::instance('321', 'Included objects', 'Yes, it is supported', $author, $comments);
        $site     = Site::instance('1', 'JSON API Samples', [$post]);

        $encoder = Encoder::instance([
            Author::class  => AuthorSchema::class,
            Comment::class => CommentSchema::class,
            Post::class    => PostSchema::class,
            Site::class    => SiteSchema::class
        ])->withEncodeOptions(JSON_PRETTY_PRINT);

        $result = $encoder
            ->withUrlPrefix('http://example.com')
            ->withIncludedPaths([
                'posts',
                'posts.author',
                'posts.comments',
            ])
            ->encodeData($site);

        return $result;
    }
public function getIncludedObjectsExample(): string
    {
        $author   = Author::instance('123', 'John', 'Dow');
        $comments = [
            Comment::instance('456', 'Included objects work as easy as basic ones', $author),
            Comment::instance('789', 'Let\'s try!', $author),
        ];
        $post     = Post::instance('321', 'Included objects', 'Yes, it is supported', $author, $comments);
        $site     = Site::instance('1', 'JSON API Samples', [$post]);

        $encoder = Encoder::instance([
            Author::class  => AuthorSchema::class,
            Comment::class => CommentSchema::class,
            Post::class    => PostSchema::class,
            Site::class    => SiteSchema::class
        ])->withEncodeOptions(JSON_PRETTY_PRINT);

        $result = $encoder
            ->withUrlPrefix('http://example.com')
            ->withIncludedPaths([
                'posts',
                'posts.author',
                'posts.comments',
            ])
            ->encodeData($site);

        return $result;
    }
public function getIncludedObjectsExample ( ) : string { $ author = Author :: instance ( '123' , 'John' , 'Dow' ) ; $ comments = [ Comment :: instance ( '456' , 'Included objects work as easy as basic ones' , $ author ) , Comment :: instance ( '789' , 'Let\'s try!' , $ author ) , ] ; $ post = Post :: instance ( '321' , 'Included objects' , 'Yes, it is supported' , $ author , $ comments ) ; $ site = Site :: instance ( '1' , 'JSON API Samples' , [ $ post ] ) ; $ encoder = Encoder :: instance ( [ Author :: class => AuthorSchema :: class , Comment :: class => CommentSchema :: class , Post :: class => PostSchema :: class , Site :: class => SiteSchema :: class ] ) -> withEncodeOptions ( JSON_PRETTY_PRINT ) ; $ result = $ encoder -> withUrlPrefix ( 'http://example.com' ) -> withIncludedPaths ( [ 'posts' , 'posts.author' , 'posts.comments' , ] ) -> encodeData ( $ site ) ; return $ result ; }
Get how objects are put to 'included'.

@return string
Get how objects are put to included .