{!! '<' . '?' . 'xml version="1.0" encoding="UTF-8"' !!}
<rss version="2.0"
	xmlns:excerpt="http://wordpress.org/export/1.0/excerpt/"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:wp="http://wordpress.org/export/1.0/"
>

<channel>
    <title>My Site</title>
    <link>http://example.com/</link>
    <description></description>
	<pubDate>Thu, 28 May 2009 16:06:40 +0000</pubDate>
	<wp:author><wp:author_id>1</wp:author_id><wp:author_login><![CDATA[admin]]></wp:author_login><wp:author_email><![CDATA[buchin@dropsugar.com]]></wp:author_email><wp:author_display_name><![CDATA[admin]]></wp:author_display_name><wp:author_first_name><![CDATA[]]></wp:author_first_name><wp:author_last_name><![CDATA[]]></wp:author_last_name></wp:author>

	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<wp:wxr_version>1.0</wp:wxr_version>
	<wp:base_site_url>http://example.com/</wp:base_site_url>
    <wp:base_blog_url>http://example.com/</wp:base_blog_url>

    @for ($i = 1; $i <= $data['finishPage']; $i++)
        @php
            $key_cache = Cache::get($data['key'].$i);
            $step = (strtotime($data['start_date']) - strtotime($data['end_date'])) / ($data['finishPage'] * 20);
            $timestamp = range(strtotime($data['start_date']), strtotime($data['end_date']), $step);
        @endphp

        @foreach ($key_cache as $key => $item)
            @php
                $pubDate = date( 'D, d M Y H:i:s', $timestamp[$key] )." +0000";
                $postDate = date( 'Y-m-d H:i:s', $timestamp[$key] );
                $title = do_template( $templates->find($data['template'])->title, $item );
                $content = do_template( $templates->find($data['template'])->content, $item );
                $rand_id = rand(1000,10000);
                $slug = \Str::slug($title);
            @endphp
            <item>
                <title><![CDATA[{{ $title }}]]></title>
                <pubDate>{{ $pubDate }}</pubDate>
                <dc:creator><![CDATA[Admin]]></dc:creator>
                <wp:postmeta>
                    <wp:meta_key>_byline</wp:meta_key>
                    <wp:meta_value>Admin</wp:meta_value>
                </wp:postmeta>

                <guid isPermaLink="false">http://example.com/?p={{ $rand_id }}</guid>
                <description></description>
                <content:encoded><![CDATA[{!! $content !!}]]></content:encoded>
                <excerpt:encoded><![CDATA[]]></excerpt:encoded>
                <wp:post_id>{{ $rand_id }}</wp:post_id>
                <wp:post_date>{{ $postDate }}</wp:post_date>
                <wp:post_date_gmt>{{ $postDate }}</wp:post_date_gmt>
                <wp:comment_status>open</wp:comment_status>
                <wp:ping_status>closed</wp:ping_status>
                <wp:post_name>{{ $slug }}</wp:post_name>

                <wp:status>publish</wp:status>
                <wp:post_parent>0</wp:post_parent>
                <wp:menu_order>0</wp:menu_order>
                <wp:post_type>post</wp:post_type>
                <wp:post_password></wp:post_password>

                <wp:postmeta>
                    <wp:meta_key>_old_id</wp:meta_key>
                    <wp:meta_value>{{ $rand_id }}</wp:meta_value>
                </wp:postmeta>

            </item>
        @endforeach
    @endfor
</channel>
</rss>
