Files
cachet-docker/src/Http/Controllers/AtomController.php
Valentin PRUGNAUD 08a016ff2b Language improvements
Signed-off-by: Graham Campbell <graham@mineuk.com>
2015-01-05 11:14:04 +00:00

47 lines
1.3 KiB
PHP

<?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 Roumen\Feed\Facades\Feed;
class AtomController extends Controller
{
/**
* Generates an Atom feed of all incidents.
*
* @return \Illuminate\Http\Response
*/
public function feedAction()
{
$feed = Feed::make();
$feed->title = Setting::get('app_name');
$feed->description = trans('cachet.feed');
$feed->link = Setting::get('app_domain');
$feed->setDateFormat('datetime');
Incident::get()->map(function ($incident) use ($feed) {
if ($incident->component) {
$componentName = $incident->component->name;
} else {
$componentName = null;
}
$feed->add(
$incident->name,
Setting::get('app_name'),
Setting::get('app_domain'),
$incident->created_at,
($componentName === null ? $incident->humanStatus : $componentName.' '.$incident->humanStatus),
$incident->message
);
});
return $feed->render('atom');
}
}