Cachet/app/Presenters/Traits/TimestampsTrait.php
James Brooks a0f2d6642e Add incident column for when an incident occurred at (#2212)
Add incident column for when an incident occurred at. Closes #2208
[ci skip] [skip ci]
2016-10-29 17:25:52 +01:00

66 lines
1.5 KiB
PHP

<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Presenters\Traits;
use CachetHQ\Cachet\Dates\DateFactory;
use Illuminate\Support\Facades\Config;
/**
* This is the timestamps trait.
*
* @author Joseph Cohen <joe@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
* @author James Brooks <james@alt-three.com>
*/
trait TimestampsTrait
{
/**
* Present formatted date time.
*
* @return string
*/
public function created_at()
{
return app(DateFactory::class)->make($this->wrappedObject->created_at)->toDateTimeString();
}
/**
* Present formatted date time.
*
* @return string
*/
public function updated_at()
{
return app(DateFactory::class)->make($this->wrappedObject->updated_at)->toDateTimeString();
}
/**
* Present formatted date time.
*
* @return string
*/
public function deleted_at()
{
return app(DateFactory::class)->make($this->wrappedObject->deleted_at)->toDateTimeString();
}
/**
* Get the incident date format setting, or fallback to a sane default.
*
* @return string
*/
protected function incidentDateFormat()
{
return Config::get('setting.incident_date_format', 'l jS F Y H:i:s');
}
}