diff --git a/app/Commands/Component/AddComponentCommand.php b/app/Commands/Component/AddComponentCommand.php index 4952bf57..4f43e61e 100644 --- a/app/Commands/Component/AddComponentCommand.php +++ b/app/Commands/Component/AddComponentCommand.php @@ -61,9 +61,12 @@ class AddComponentCommand * @var string[] */ public $rules = [ - 'name' => 'required|string', - 'status' => 'required|integer', - 'link' => 'url', + 'name' => 'required|string', + 'description' => 'string', + 'status' => 'required|integer', + 'link' => 'url', + 'order' => 'integer', + 'group_id' => 'integer', ]; /** diff --git a/app/Commands/Component/UpdateComponentCommand.php b/app/Commands/Component/UpdateComponentCommand.php index b50d0a5f..d34ee4d9 100644 --- a/app/Commands/Component/UpdateComponentCommand.php +++ b/app/Commands/Component/UpdateComponentCommand.php @@ -16,7 +16,7 @@ use CachetHQ\Cachet\Models\Component; class UpdateComponentCommand { /** - * The component. + * The component to update. * * @var \CachetHQ\Cachet\Models\Component */ @@ -70,9 +70,12 @@ class UpdateComponentCommand * @var string[] */ public $rules = [ - 'name' => 'string', - 'status' => 'integer', - 'link' => 'url', + 'name' => 'string', + 'description' => 'string', + 'status' => 'integer', + 'link' => 'url', + 'order' => 'integer', + 'group_id' => 'integer', ]; /** diff --git a/app/Commands/Incident/ReportIncidentCommand.php b/app/Commands/Incident/ReportIncidentCommand.php index 073e183a..25486c75 100644 --- a/app/Commands/Incident/ReportIncidentCommand.php +++ b/app/Commands/Incident/ReportIncidentCommand.php @@ -62,6 +62,21 @@ class ReportIncidentCommand */ public $notify; + /** + * The validation rules. + * + * @var string[] + */ + public $rules = [ + 'name' => 'required|string', + 'status' => 'required|integer', + 'message' => 'string', + 'visible' => 'boolean', + 'component_id' => 'integer', + 'component_status' => 'integer', + 'notify' => 'boolean', + ]; + /** * Create a new report incident command instance. * diff --git a/app/Commands/Incident/ReportMaintenanceCommand.php b/app/Commands/Incident/ReportMaintenanceCommand.php index 82105055..2f0a6405 100644 --- a/app/Commands/Incident/ReportMaintenanceCommand.php +++ b/app/Commands/Incident/ReportMaintenanceCommand.php @@ -41,6 +41,18 @@ class ReportMaintenanceCommand */ public $timestamp; + /** + * The validation rules. + * + * @var string[] + */ + public $rules = [ + 'name' => 'required|string', + 'message' => 'string', + 'notify' => 'boolean', + 'timestamp' => 'string', + ]; + /** * Create a new report maintenance command instance. * diff --git a/app/Commands/Incident/UpdateIncidentCommand.php b/app/Commands/Incident/UpdateIncidentCommand.php index bf6b56f3..d271bca2 100644 --- a/app/Commands/Incident/UpdateIncidentCommand.php +++ b/app/Commands/Incident/UpdateIncidentCommand.php @@ -16,7 +16,7 @@ use CachetHQ\Cachet\Models\Incident; class UpdateIncidentCommand { /** - * The incident. + * The incident to update. * * @var \CachetHQ\Cachet\Models\Incident */ @@ -71,6 +71,21 @@ class UpdateIncidentCommand */ public $notify; + /** + * The validation rules. + * + * @var string[] + */ + public $rules = [ + 'name' => 'string', + 'status' => 'integer', + 'message' => 'string', + 'visible' => 'boolean', + 'component_id' => 'integer', + 'component_status' => 'integer', + 'notify' => 'boolean', + ]; + /** * Create a new update incident command instance. * @@ -82,10 +97,11 @@ class UpdateIncidentCommand * @param int $component_id * @param int $component_status * @param bool $notify + * @param string|null $incidentDate * * @return void */ - public function __construct(Incident $incident, $name, $status, $message, $visible, $component_id, $component_status, $notify) + public function __construct(Incident $incident, $name, $status, $message, $visible, $component_id, $component_status, $notify, $incident_date = null) { $this->incident = $incident; $this->name = $name; @@ -95,5 +111,6 @@ class UpdateIncidentCommand $this->component_id = $component_id; $this->component_status = $component_status; $this->notify = $notify; + $this->incident_date = $incident_date; } } diff --git a/app/Commands/Metric/AddMetricCommand.php b/app/Commands/Metric/AddMetricCommand.php index b65072ce..f946f628 100644 --- a/app/Commands/Metric/AddMetricCommand.php +++ b/app/Commands/Metric/AddMetricCommand.php @@ -68,13 +68,16 @@ class AddMetricCommand * @var string[] */ public $rules = [ - 'name' => 'required', - 'suffix' => 'required', + 'name' => 'required|string', + 'suffix' => 'required|string', + 'description' => 'string', 'display_chart' => 'boolean', 'default_value' => 'numeric', + 'calc_type' => 'integer', + 'display_chart' => 'integer', 'places' => 'numeric|min:0|max:4', ]; - + /** * Create a new add metric command instance. * diff --git a/app/Commands/Metric/AddMetricPointCommand.php b/app/Commands/Metric/AddMetricPointCommand.php index e0b676b8..9ecdad1a 100644 --- a/app/Commands/Metric/AddMetricPointCommand.php +++ b/app/Commands/Metric/AddMetricPointCommand.php @@ -34,21 +34,31 @@ class AddMetricPointCommand * * @var string */ - public $createdAt; + public $created_at; + + /** + * The validation rules. + * + * @var string[] + */ + public $rules = [ + 'value' => 'integer', + 'created_at' => 'string', + ]; /** * Create a new add metric point command instance. * * @param \CachetHQ\Cachet\Models\Metric $metric * @param int $value - * @param string $createdAt + * @param string $created_at * * @return void */ - public function __construct(Metric $metric, $value, $createdAt) + public function __construct(Metric $metric, $value, $created_at) { $this->metric = $metric; $this->value = $value; - $this->createdAt = $createdAt; + $this->created_at = $created_at; } } diff --git a/app/Commands/Metric/UpdateMetricCommand.php b/app/Commands/Metric/UpdateMetricCommand.php index b6284f89..3c4674fe 100644 --- a/app/Commands/Metric/UpdateMetricCommand.php +++ b/app/Commands/Metric/UpdateMetricCommand.php @@ -79,8 +79,11 @@ class UpdateMetricCommand public $rules = [ 'name' => 'string', 'suffix' => 'string', + 'description' => 'string', 'display_chart' => 'boolean', 'default_value' => 'numeric', + 'calc_type' => 'integer', + 'display_chart' => 'integer', 'places' => 'numeric|min:0|max:4', ]; diff --git a/app/Commands/Metric/UpdateMetricPointCommand.php b/app/Commands/Metric/UpdateMetricPointCommand.php index 7d3cdb9f..420a41e4 100644 --- a/app/Commands/Metric/UpdateMetricPointCommand.php +++ b/app/Commands/Metric/UpdateMetricPointCommand.php @@ -42,7 +42,17 @@ class UpdateMetricPointCommand * * @var string */ - public $createdAt; + public $created_at; + + /** + * The validation rules. + * + * @var string[] + */ + public $rules = [ + 'value' => 'integer', + 'created_at' => 'string', + ]; /** * Create a new update metric point command instance. @@ -50,15 +60,15 @@ class UpdateMetricPointCommand * @param \CachetHQ\Cachet\Models\MetricPoint $point * @param \CachetHQ\Cachet\Models\Metric $metric * @param int $value - * @param string $createdAt + * @param string $created_at * * @return void */ - public function __construct(MetricPoint $point, Metric $metric, $value, $createdAt) + public function __construct(MetricPoint $point, Metric $metric, $value, $created_at) { $this->point = $point; $this->metric = $metric; $this->value = $value; - $this->createdAt = $createdAt; + $this->created_at = $created_at; } } diff --git a/app/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php b/app/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php index 03802fd7..bbaf7ac2 100644 --- a/app/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php +++ b/app/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php @@ -30,6 +30,13 @@ class UpdateIncidentCommandHandler $incident = $command->incident; $incident->update($this->filterIncidentData($command)); + if ($incidentDate = $command->incident_date) { + $incident->update([ + 'created_at' => $incidentDate, + 'updated_at' => $incidentDate, + ]); + } + // Update the component. if ($command->component_id) { Component::find($command->component_id)->update([ diff --git a/app/Handlers/Commands/Metric/UpdateMetricPointCommandHandler.php b/app/Handlers/Commands/Metric/UpdateMetricPointCommandHandler.php index 794eebeb..823d254e 100644 --- a/app/Handlers/Commands/Metric/UpdateMetricPointCommandHandler.php +++ b/app/Handlers/Commands/Metric/UpdateMetricPointCommandHandler.php @@ -28,7 +28,7 @@ class UpdateMetricPointCommandHandler { $point = $command->point; $metric = $command->metric; - $createdAt = $command->createdAt; + $createdAt = $command->created_at; $data = [ 'metric_id' => $metric->id, diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 443481fa..47558194 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -112,6 +112,8 @@ class IncidentController extends Controller */ public function createIncidentAction() { + $incidentDate = null; + if ($createdAt = Binput::get('created_at')) { $incidentDate = Date::createFromFormat('d/m/Y H:i', $createdAt, Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone')); } @@ -124,15 +126,9 @@ class IncidentController extends Controller Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), - Binput::get('notify', true) + Binput::get('notify', true), + $incidentDate )); - - if (isset($incidentDate)) { - $incident->update([ - 'created_at' => $incidentDate, - 'updated_at' => $incidentDate, - ]); - } } catch (ValidationException $e) { return Redirect::route('dashboard.incidents.add') ->withInput(Binput::all())