User Carbon to query scheduled incidents

This commit is contained in:
Joseph Cohen
2015-03-11 15:58:48 -06:00
parent 9098ae1b96
commit 3c46387dd8

View File

@@ -2,7 +2,7 @@
namespace CachetHQ\Cachet\Models;
use CachetHQ\Cachet\Facades\Setting as SettingFacade;
use Carbon\Carbon;
use CachetHQ\Cachet\Transformers\IncidentTransformer;
use Dingo\Api\Transformer\TransformableInterface;
use Illuminate\Database\Eloquent\Model;
@@ -70,9 +70,7 @@ class Incident extends Model implements TransformableInterface, PresenterInterfa
*/
public function scopeScheduled($query)
{
$timestamp = (new Date())->setTimezone(SettingFacade::get('app_timezone'))->format('Y-m-d H:i:s');
return $query->where('status', 0)->where('scheduled_at', '>=', $timestamp);
return $query->where('status', 0)->where('scheduled_at', '>=', Carbon::now());
}
/**
@@ -85,9 +83,7 @@ class Incident extends Model implements TransformableInterface, PresenterInterfa
public function scopeNotScheduled($query)
{
return $query->where(function ($query) {
$timestamp = (new Date())->setTimezone(SettingFacade::get('app_timezone'))->format('Y-m-d H:i:s');
return $query->whereNull('scheduled_at')->orWhere('scheduled_at', '<=', $timestamp);
return $query->whereNull('scheduled_at')->orWhere('scheduled_at', '<=', Carbon::now());
});
}