forked from ludoguenet/laranudge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e6fd17
commit 517ca0d
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Nudge; | ||
use Illuminate\Http\Response; | ||
|
||
class RSSFeedController extends Controller | ||
{ | ||
public function __invoke(): Response | ||
{ | ||
$nudges = Nudge::latest()->get(); | ||
|
||
return response()->view('rss', [ | ||
'nudges' => $nudges, | ||
])->header('Content-Type', 'text/xml'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?= | ||
'<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL | ||
?> | ||
<rss version="2.0"> | ||
<channel> | ||
<title> | ||
<![CDATA[ laranudge.com ]]> | ||
</title> | ||
<link> | ||
<![CDATA[ https://laranudge.com/feed ]]> | ||
</link> | ||
<description> | ||
<![CDATA[ Share your favourite Laravel tips ]]> | ||
</description> | ||
<language>en</language> | ||
<pubDate>{{ now() }}</pubDate> | ||
|
||
@foreach($nudges as $nudge) | ||
<item> | ||
<title> | ||
<![CDATA[{{ $nudge->content }}]]> | ||
</title> | ||
<description> | ||
<![CDATA[{!! $nudge->code !!}]]> | ||
</description> | ||
<pubDate>{{ $nudge->created_at->toRssString() }}</pubDate> | ||
</item> | ||
@endforeach | ||
</channel> | ||
</rss> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters