la_bloger/app/Http/Controllers/FeedController.php

24 lines
628 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Channel;
use App\Models\Publication;
use Illuminate\Http\Response;
class FeedController extends Controller
{
public function index(Channel $channel): Response
{
$publications = Publication::published()
->forChannel($channel)
->with(['post.author', 'channel.prefixes'])
->latest('published_at')
->limit(20)
->get();
return response()
->view('theme::feed', compact('publications', 'channel'))
->header('Content-Type', 'application/rss+xml; charset=UTF-8');
}
}