4個のファイルの変更、47行の追加、0行の削除
@ -0,0 +1,23 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use Illuminate\Support\Facades\DB; |
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Support\Facades\Log; |
||||
|
||||
class RssFeedController extends Controller { |
||||
public function feed () { |
||||
$select = ['id', 'user_id', 'title', 'slug', 'publish_date', 'message']; |
||||
$posts = DB::table('blg_content')->select($select)->where('isPost', true)->where('public_status', 0)->orderBy('id', 'desc')->limit(50)->get(); |
||||
|
||||
foreach ($posts as $k => $v) { |
||||
$userd = DB::table('users')->where('id', $v->user_id)->first(); |
||||
$userd = DB::table('usr_profile')->where('user_id', $v->user_id)->first(); |
||||
$v->user = $userd->display_name; |
||||
unset($posts[$k]->user_id); |
||||
} |
||||
|
||||
return response()->view('rss.feed', ['posts' => $posts])->header('Content-Type', 'application/xml'); |
||||
} |
||||
} |
@ -0,0 +1,22 @@
|
||||
<?= |
||||
'<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL
|
||||
?> |
||||
<rss version="2.0"> |
||||
<channel> |
||||
<title><![CDATA[{{ env('APP_NAME') }}]]></title> |
||||
<link><![CDATA[{{ env('APP_URL') }}/feed ]]></link> |
||||
<description><![CDATA[ テクニカル諏訪子のホームページです。ゲーム及びテクノロジー関係ブログですわ♡ ]]></description> |
||||
<language>ja</language> |
||||
<pubDate>{{ now() }}</pubDate> |
||||
|
||||
@foreach($posts as $post) |
||||
<item> |
||||
<title><![CDATA[{{ $post->title }}]]></title> |
||||
<link>{{ env('APP_URL') }}/blog/{{ $post->slug }}</link> |
||||
<description><![CDATA[{!! $post->message !!}]]></description> |
||||
<author><![CDATA[{{ $post->user }}]]></author> |
||||
<pubDate>{{ date('Y-m-d H:i:s', $post->publish_date) }}</pubDate> |
||||
</item> |
||||
@endforeach |
||||
</channel> |
||||
</rss> |
読み込み中…
新しいイシューから参照