Commit fb705e55 by Bagus Pambudi

rss web profile sementara

parent 6b00b506
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Webprofile\Posts;
class RssFeedController extends Controller
{
public function feed()
{
$posts = Posts::where('post_status', 't')->
orderBy('created_at', 'desc')->
limit(50)->get();
return response()->view('rss.feed', compact('posts'))->header('Content-Type', 'application/xml');
}
}
\ No newline at end of file
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
//
}
<?=
'<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL
?>
<rss version="2.0">
<channel>
<title><![CDATA[ DevDojo ]]></title>
<link><![CDATA[ https://localhost/feed ]]></link>
<description><![CDATA[ BERITA UNESA ]]></description>
<language>en</language>
<pubDate>{{ now() }}</pubDate>
@foreach($posts as $post)
<item>
<title><![CDATA[{{ $post->title }}]]></title>
<link>{{ $post->slug }}</link>
<description><![CDATA[{!! $post->body !!}]]></description>
<category>{{ $post->category }}</category>
{{-- <author><![CDATA[{{ $post->slug }}]]></author>--}}
<guid>{{ $post->id }}</guid>
<pubDate>{{ $post->created_at->toRssString() }}</pubDate>
</item>
@endforeach
</channel>
</rss>
\ No newline at end of file
...@@ -15,3 +15,4 @@ Auth::routes(); ...@@ -15,3 +15,4 @@ Auth::routes();
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('feed', 'RssFeedController@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