Fix schedules.completed_at not being null. Closes #2509

This commit is contained in:
James Brooks
2017-05-06 09:57:30 +01:00
parent 0e70727e38
commit 8bace140e5
3 changed files with 17 additions and 2 deletions

View File

@@ -92,7 +92,7 @@ class CreateScheduleCommandHandler
];
$availableParams = array_filter($params, function ($val) {
return $val !== null;
return $val !== null && $val !== '';
});
return $availableParams;

View File

@@ -19,6 +19,11 @@ use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use McCool\LaravelAutoPresenter\HasPresenter;
/**
* This is the schedule class.
*
* @author James Brooks <james@alt-three.com>
*/
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.
*

View File

@@ -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');
}
}