Commit 29a0ebf6 by Triyah Fatmawati

RSS new (PPM)

parent 2ea6667b
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Webprofile\Posts;
class RssFeedNewController extends Controller
{
public function feed()
{
$setting = webprofilesetting();
// $posts = Posts::where('post_status', 't')->
// orderBy('post_date', 'desc')->
// limit(10)->get();
$posts = Posts::orderBy('created_at')->get();
dd($setting, $posts);
$data = response()->view('rss.feed', compact('posts','setting'))->header('Content-Type', 'application/xml');
return strip_tags($data);
}
}
<?=
'<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL
?>
<rss version="2.0">
<channel>
<title><![CDATA[ RSS {{$setting['web_title']}}]]></title>
<link><![CDATA[ {{ url('') }}]]></link>
<description><![CDATA[ BERITA {{$setting['web_title']}} ]]></description>
<language>en</language>
<pubDate>{{ now() }}</pubDate>
@foreach($posts as $post)
{{-- <image>
<url>{{ $setting['url_static'] . '/' . $setting['directory'] . '/thumbnail/' . $post->thumbnail }}</url>
</image>--}}
<item>
<title>{{ $post->title }}</title>
<image>
<url>{{ $setting['url_static'] . '/' . $setting['directory'] . '/thumbnail/' . $post->thumbnail }}</url>
</image>
<link>{{ url('post/'.$post['slug'])}}</link>
<description>{!! strip_tags(substr(html_entity_decode($post->content,ENT_COMPAT,"UTF-8"),0 , 250)) !!}</description>
{{-- <description><![CDATA[{!! $post->content !!}]]></description>--}}
<category>{{ $post->rCategory->name }}</category>
{{-- <author><![CDATA[{{ $post->slug }}]]></author>--}}
{{-- <guid>{{ $post->id }}</guid>--}}
<pubDate>{{ $post->post_date }}</pubDate>
</item>
@endforeach
</channel>
</rss>
\ No newline at end of file
...@@ -22,3 +22,4 @@ Route::get('reload-captcha', 'Auth\LoginController@reloadCaptcha')->name('reload ...@@ -22,3 +22,4 @@ Route::get('reload-captcha', 'Auth\LoginController@reloadCaptcha')->name('reload
Route::post('/change-language', 'TranslateController@changeLocale')->name('language'); Route::post('/change-language', 'TranslateController@changeLocale')->name('language');
Route::get('/home', 'HomeController@index')->name('home'); Route::get('/home', 'HomeController@index')->name('home');
Route::get('rss', 'RssFeedController@feed'); Route::get('rss', 'RssFeedController@feed');
Route::get('rssnew', 'RssFeedNewController@feed');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment