Added presenters and timezone locales with diff and popover

This commit is contained in:
Joseph Cohen
2015-01-07 18:48:10 -06:00
parent ff73992050
commit ffbe9b31bf
10 changed files with 169 additions and 21 deletions
+50
View File
@@ -0,0 +1,50 @@
<?php
namespace CachetHQ\Cachet\Presenters;
use CachetHQ\Cachet\Models\Incident;
use Jenssegers\Date\Date;
use McCool\LaravelAutoPresenter\BasePresenter;
class IncidentPresenter extends BasePresenter
{
/**
* Create a incident presenter instance.
*
* @param \CachetHQ\Cachet\Models\Incident $incident
*/
public function __construct(Incident $incident)
{
$this->resource = $incident;
}
/**
* Present diff for humans date time.
*
* @return string
*/
public function created_at_diff()
{
return (new Date($this->resource->created_at))->diffForHumans();
}
/**
* Present formated date time.
*
* @return string
*/
public function created_at_formated()
{
return ucfirst((new Date($this->resource->created_at))->format('l j F Y H:i:s'));
}
/**
* Present formated date time.
*
* @return string
*/
public function created_at_iso()
{
return $this->resource->created_at->toISO8601String();
}
}