Namespaced models and refactored filters

This commit is contained in:
Graham Campbell
2015-01-02 00:18:19 +00:00
parent 15a6694865
commit 0ccb5e289c
66 changed files with 310 additions and 195 deletions

View File

@@ -0,0 +1,46 @@
<?php
namespace CachetHQ\Cachet\Http\Controllers;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\Setting;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Response;
use Thujohn\Rss\RssFacade;
class RssController extends Controller
{
/**
* Generates an RSS feed of all incidents.
*
* @return \Illuminate\Http\Response
*/
public function feedAction()
{
$feed = RssFacade::feed('2.0', 'UTF-8');
$feed->channel([
'title' => Setting::get('app_name'),
'description' => 'Status Feed',
'link' => Setting::get('app_domain'),
]);
Incident::get()->map(function ($incident) use ($feed) {
if ($incident->component) {
$componentName = $incident->component->name;
} else {
$componentName = null;
}
$feed->item([
'title' => $incident->name,
'message' => $incident->message,
'component' => $componentName,
'status' => $incident->humanStatus,
'created_at' => $incident->created_at,
'updated_at' => $incident->updated_at,
]);
});
return Response::make($feed, 200, ['Content-Type' => 'text/xml']);
}
}