From 8bace140e56afeab4816a08b92c18c484279aed5 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Sat, 6 May 2017 09:57:30 +0100 Subject: [PATCH] Fix schedules.completed_at not being null. Closes #2509 --- .../Schedule/CreateScheduleCommandHandler.php | 2 +- app/Models/Schedule.php | 15 +++++++++++++++ app/Presenters/SchedulePresenter.php | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Bus/Handlers/Commands/Schedule/CreateScheduleCommandHandler.php b/app/Bus/Handlers/Commands/Schedule/CreateScheduleCommandHandler.php index 403131a2..92ec22cc 100644 --- a/app/Bus/Handlers/Commands/Schedule/CreateScheduleCommandHandler.php +++ b/app/Bus/Handlers/Commands/Schedule/CreateScheduleCommandHandler.php @@ -92,7 +92,7 @@ class CreateScheduleCommandHandler ]; $availableParams = array_filter($params, function ($val) { - return $val !== null; + return $val !== null && $val !== ''; }); return $availableParams; diff --git a/app/Models/Schedule.php b/app/Models/Schedule.php index 47b6d56a..3154c4e9 100644 --- a/app/Models/Schedule.php +++ b/app/Models/Schedule.php @@ -19,6 +19,11 @@ use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; use McCool\LaravelAutoPresenter\HasPresenter; +/** + * This is the schedule class. + * + * @author James Brooks + */ class Schedule extends Model implements HasPresenter { use SearchableTrait, SortableTrait, ValidatingTrait; @@ -44,6 +49,16 @@ class Schedule extends Model implements HasPresenter */ const COMPLETE = 2; + /** + * The model's attributes. + * + * @var string[] + */ + protected $attributes = [ + 'status' => self::UPCOMING, + 'completed_at' => null, + ]; + /** * The attributes that should be casted to native types. * diff --git a/app/Presenters/SchedulePresenter.php b/app/Presenters/SchedulePresenter.php index cfc98a5f..efff4d2b 100644 --- a/app/Presenters/SchedulePresenter.php +++ b/app/Presenters/SchedulePresenter.php @@ -210,7 +210,7 @@ class SchedulePresenter extends BasePresenter implements Arrayable */ public function completed_at_datetimepicker() { - if ($this->wrappedObject->completed_at !== '0000-00-00 00:00:00') { + if ($this->wrappedObject->completed_at) { return $this->dates->make($this->wrappedObject->completed_at)->format('Y-m-d H:i'); } }