Merge pull request #866 from cachethq/commands
[WIP] First steps to Commands
This commit is contained in:
90
app/Commands/Component/AddComponentCommand.php
Normal file
90
app/Commands/Component/AddComponentCommand.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?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\Commands\Component;
|
||||
|
||||
class AddComponentCommand
|
||||
{
|
||||
/**
|
||||
* The component name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* The component description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* The component status.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $status;
|
||||
|
||||
/**
|
||||
* The component link.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $link;
|
||||
|
||||
/**
|
||||
* The component order.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $order;
|
||||
|
||||
/**
|
||||
* The component group.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $group_id;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $rules = [
|
||||
'name' => 'required|string',
|
||||
'status' => 'required|integer',
|
||||
'link' => 'url',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new add component command instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $description
|
||||
* @param int $status
|
||||
* @param string $link
|
||||
* @param int $order
|
||||
* @param int $group_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name, $description, $status, $link, $order, $group_id)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->description = $description;
|
||||
$this->status = (int) $status;
|
||||
$this->link = $link;
|
||||
$this->order = $order;
|
||||
$this->group_id = $group_id;
|
||||
}
|
||||
}
|
||||
36
app/Commands/Component/RemoveComponentCommand.php
Normal file
36
app/Commands/Component/RemoveComponentCommand.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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\Commands\Component;
|
||||
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
|
||||
class RemoveComponentCommand
|
||||
{
|
||||
/**
|
||||
* The component to remove.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Component
|
||||
*/
|
||||
public $component;
|
||||
|
||||
/**
|
||||
* Create a new remove component command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Component $component
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Component $component)
|
||||
{
|
||||
$this->component = $component;
|
||||
}
|
||||
}
|
||||
53
app/Commands/ComponentGroup/AddComponentGroupCommand.php
Normal file
53
app/Commands/ComponentGroup/AddComponentGroupCommand.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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\Commands\ComponentGroup;
|
||||
|
||||
class AddComponentGroupCommand
|
||||
{
|
||||
/**
|
||||
* The component group name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* The component group description.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $order;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $rules = [
|
||||
'name' => 'required|string',
|
||||
'order' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a add component group command instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $order
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name, $order)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->order = (int) $order;
|
||||
}
|
||||
}
|
||||
36
app/Commands/ComponentGroup/RemoveComponentGroupCommand.php
Normal file
36
app/Commands/ComponentGroup/RemoveComponentGroupCommand.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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\Commands\ComponentGroup;
|
||||
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
|
||||
class RemoveComponentGroupCommand
|
||||
{
|
||||
/**
|
||||
* The component group to remove.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\ComponentGroup
|
||||
*/
|
||||
public $group;
|
||||
|
||||
/**
|
||||
* Create a new remove component group command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\ComponentGroup $group
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ComponentGroup $group)
|
||||
{
|
||||
$this->group = $group;
|
||||
}
|
||||
}
|
||||
36
app/Commands/Incident/RemoveIncidentCommand.php
Normal file
36
app/Commands/Incident/RemoveIncidentCommand.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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\Commands\Incident;
|
||||
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
|
||||
class RemoveIncidentCommand
|
||||
{
|
||||
/**
|
||||
* The incident to remove.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Incident
|
||||
*/
|
||||
public $incident;
|
||||
|
||||
/**
|
||||
* Create a new remove incident command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Incident $incident)
|
||||
{
|
||||
$this->incident = $incident;
|
||||
}
|
||||
}
|
||||
88
app/Commands/Incident/ReportIncidentCommand.php
Normal file
88
app/Commands/Incident/ReportIncidentCommand.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?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\Commands\Incident;
|
||||
|
||||
class ReportIncidentCommand
|
||||
{
|
||||
/**
|
||||
* The incident name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* The incident status.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $status;
|
||||
|
||||
/**
|
||||
* The incident message.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $message;
|
||||
|
||||
/**
|
||||
* The incident visibility.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $visible;
|
||||
|
||||
/**
|
||||
* The incident component.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $component_id;
|
||||
|
||||
/**
|
||||
* The component status.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $component_status;
|
||||
|
||||
/**
|
||||
* Whether to notify about the incident or not.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $notify;
|
||||
|
||||
/**
|
||||
* Create a new report incident command instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $status
|
||||
* @param string $message
|
||||
* @param int $visible
|
||||
* @param int $component_id
|
||||
* @param int $component_status
|
||||
* @param bool $notify
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name, $status, $message, $visible, $component_id, $component_status, $notify)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->status = $status;
|
||||
$this->message = $message;
|
||||
$this->visible = $visible;
|
||||
$this->component_id = $component_id;
|
||||
$this->component_status = $component_status;
|
||||
$this->notify = $notify;
|
||||
}
|
||||
}
|
||||
61
app/Commands/Incident/ReportMaintenanceCommand.php
Normal file
61
app/Commands/Incident/ReportMaintenanceCommand.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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\Commands\Incident;
|
||||
|
||||
class ReportMaintenanceCommand
|
||||
{
|
||||
/**
|
||||
* The maintenance name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* The maintenance message.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $message;
|
||||
|
||||
/**
|
||||
* Whether to notify about the maintenance or not.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $notify;
|
||||
|
||||
/**
|
||||
* Timestamp of when the maintenance is due to start.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $timestamp;
|
||||
|
||||
/**
|
||||
* Create a new report maintenance command instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $message
|
||||
* @param bool $notify
|
||||
* @param string $timestamp
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name, $message, $notify, $timestamp)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->message = $message;
|
||||
$this->notify = $notify;
|
||||
$this->timestamp = $timestamp;
|
||||
}
|
||||
}
|
||||
101
app/Commands/Metric/AddMetricCommand.php
Normal file
101
app/Commands/Metric/AddMetricCommand.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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\Commands\Metric;
|
||||
|
||||
class AddMetricCommand
|
||||
{
|
||||
/**
|
||||
* The metric name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* The metric suffix.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $suffix;
|
||||
|
||||
/**
|
||||
* The metric description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* The metric default value.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public $default_value;
|
||||
|
||||
/**
|
||||
* The metric calculation type.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $calc_type;
|
||||
|
||||
/**
|
||||
* The metric display chart.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $display_chart;
|
||||
|
||||
/**
|
||||
* The metric decimal places.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $places;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $rules = [
|
||||
'name' => 'required',
|
||||
'suffix' => 'required',
|
||||
'display_chart' => 'boolean',
|
||||
'default_value' => 'numeric',
|
||||
'places' => 'numeric|min:0|max:4',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new add metric command instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $suffix
|
||||
* @param string $description
|
||||
* @param float $default_value
|
||||
* @param int $calc_type
|
||||
* @param int $display_chart
|
||||
* @param int $places
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name, $suffix, $description, $default_value, $calc_type, $display_chart, $places)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->suffix = $suffix;
|
||||
$this->description = $description;
|
||||
$this->default_value = $default_value;
|
||||
$this->calc_type = $calc_type;
|
||||
$this->display_chart = $display_chart;
|
||||
$this->places = $places;
|
||||
}
|
||||
}
|
||||
54
app/Commands/Metric/AddMetricPointCommand.php
Normal file
54
app/Commands/Metric/AddMetricPointCommand.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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\Commands\Metric;
|
||||
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
|
||||
class AddMetricPointCommand
|
||||
{
|
||||
/**
|
||||
* The metric to add.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Metric
|
||||
*/
|
||||
public $metric;
|
||||
|
||||
/**
|
||||
* The metric point value.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* The metric point created at.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $createdAt;
|
||||
|
||||
/**
|
||||
* Create a new add metric point command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Metric $metric
|
||||
* @param int $value
|
||||
* @param string $createdAt
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Metric $metric, $value, $createdAt)
|
||||
{
|
||||
$this->metric = $metric;
|
||||
$this->value = $value;
|
||||
$this->createdAt = $createdAt;
|
||||
}
|
||||
}
|
||||
36
app/Commands/Metric/RemoveMetricCommand.php
Normal file
36
app/Commands/Metric/RemoveMetricCommand.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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\Commands\Metric;
|
||||
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
|
||||
class RemoveMetricCommand
|
||||
{
|
||||
/**
|
||||
* The metric to remove.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Metric
|
||||
*/
|
||||
public $metric;
|
||||
|
||||
/**
|
||||
* Create a new remove metric command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Metric $metric
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Metric $metric)
|
||||
{
|
||||
$this->metric = $metric;
|
||||
}
|
||||
}
|
||||
36
app/Commands/Metric/RemoveMetricPointCommand.php
Normal file
36
app/Commands/Metric/RemoveMetricPointCommand.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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\Commands\Metric;
|
||||
|
||||
use CachetHQ\Cachet\Models\MetricPoint;
|
||||
|
||||
class RemoveMetricPointCommand
|
||||
{
|
||||
/**
|
||||
* The metric point to remove.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\MetricPoint
|
||||
*/
|
||||
public $metricPoint;
|
||||
|
||||
/**
|
||||
* Create a new remove metric point command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\MetricPoint $metricPoint
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MetricPoint $metricPoint)
|
||||
{
|
||||
$this->metricPoint = $metricPoint;
|
||||
}
|
||||
}
|
||||
52
app/Commands/Subscriber/SubscribeSubscriberCommand.php
Normal file
52
app/Commands/Subscriber/SubscribeSubscriberCommand.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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\Commands\Subscriber;
|
||||
|
||||
class SubscribeSubscriberCommand
|
||||
{
|
||||
/**
|
||||
* The subscriber email.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $email;
|
||||
|
||||
/**
|
||||
* The subscriber auto verification.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $verified;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $rules = [
|
||||
'email' => 'required|email',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new subscribe subscriber command instance.
|
||||
*
|
||||
* @param string $email
|
||||
* @param bool $verified
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($email, $verified = false)
|
||||
{
|
||||
$this->email = $email;
|
||||
$this->verified = $verified;
|
||||
}
|
||||
}
|
||||
36
app/Commands/Subscriber/UnsubscribeSubscriberCommand.php
Normal file
36
app/Commands/Subscriber/UnsubscribeSubscriberCommand.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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\Commands\Subscriber;
|
||||
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
|
||||
class UnsubscribeSubscriberCommand
|
||||
{
|
||||
/**
|
||||
* The subscriber to unsubscribe.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $subscriber;
|
||||
|
||||
/**
|
||||
* Create a unsubscribe subscriber command instance.
|
||||
*
|
||||
* @param string $subscriber
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Subscriber $subscriber)
|
||||
{
|
||||
$this->subscriber = $subscriber;
|
||||
}
|
||||
}
|
||||
36
app/Commands/Subscriber/VerifySubscriberCommand.php
Normal file
36
app/Commands/Subscriber/VerifySubscriberCommand.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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\Commands\Subscriber;
|
||||
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
|
||||
class VerifySubscriberCommand
|
||||
{
|
||||
/**
|
||||
* The subscriber to verify.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $subscriber;
|
||||
|
||||
/**
|
||||
* Create a verify subscriber command instance.
|
||||
*
|
||||
* @param string $subscriber
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Subscriber $subscriber)
|
||||
{
|
||||
$this->subscriber = $subscriber;
|
||||
}
|
||||
}
|
||||
61
app/Commands/User/AddTeamMemberCommand.php
Normal file
61
app/Commands/User/AddTeamMemberCommand.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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\Commands\User;
|
||||
|
||||
class AddTeamMemberCommand
|
||||
{
|
||||
/**
|
||||
* The user username.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $username;
|
||||
|
||||
/**
|
||||
* The user password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $password;
|
||||
|
||||
/**
|
||||
* The user email.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $email;
|
||||
|
||||
/**
|
||||
* The user level.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $level;
|
||||
|
||||
/**
|
||||
* Create a new add team member command instance.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param string $email
|
||||
* @param int $level
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($username, $password, $email, $level)
|
||||
{
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
$this->email = $email;
|
||||
$this->level = $level;
|
||||
}
|
||||
}
|
||||
34
app/Commands/User/GenerateApiTokenCommand.php
Normal file
34
app/Commands/User/GenerateApiTokenCommand.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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\Commands\User;
|
||||
|
||||
class GenerateApiTokenCommand
|
||||
{
|
||||
/**
|
||||
* The user to generate the token.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new generate api token command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
36
app/Commands/User/RemoveUserCommand.php
Normal file
36
app/Commands/User/RemoveUserCommand.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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\Commands\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
class RemoveUserCommand
|
||||
{
|
||||
/**
|
||||
* The user to remove.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new remove user command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
34
app/Events/Component/ComponentWasAddedEvent.php
Normal file
34
app/Events/Component/ComponentWasAddedEvent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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\Events\Component;
|
||||
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
|
||||
class ComponentWasAddedEvent
|
||||
{
|
||||
/**
|
||||
* The component that was added.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Component
|
||||
*/
|
||||
public $component;
|
||||
|
||||
/**
|
||||
* Create a new component was added event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Component $component)
|
||||
{
|
||||
$this->component = $component;
|
||||
}
|
||||
}
|
||||
34
app/Events/Component/ComponentWasRemovedEvent.php
Normal file
34
app/Events/Component/ComponentWasRemovedEvent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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\Events\Component;
|
||||
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
|
||||
class ComponentWasRemovedEvent
|
||||
{
|
||||
/**
|
||||
* The component that was removed.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Component
|
||||
*/
|
||||
public $component;
|
||||
|
||||
/**
|
||||
* Create a new component was removed event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Component $component)
|
||||
{
|
||||
$this->component = $component;
|
||||
}
|
||||
}
|
||||
34
app/Events/ComponentGroup/ComponentGroupWasAddedEvent.php
Normal file
34
app/Events/ComponentGroup/ComponentGroupWasAddedEvent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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\Events\ComponentGroup;
|
||||
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
|
||||
class ComponentGroupWasAddedEvent
|
||||
{
|
||||
/**
|
||||
* The component group that was added.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\ComponentGroup
|
||||
*/
|
||||
public $group;
|
||||
|
||||
/**
|
||||
* Create a new component group was added event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ComponentGroup $group)
|
||||
{
|
||||
$this->group = $group;
|
||||
}
|
||||
}
|
||||
34
app/Events/ComponentGroup/ComponentGroupWasRemovedEvent.php
Normal file
34
app/Events/ComponentGroup/ComponentGroupWasRemovedEvent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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\Events\ComponentGroup;
|
||||
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
|
||||
class ComponentGroupWasRemovedEvent
|
||||
{
|
||||
/**
|
||||
* The component group that was removed.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\ComponentGroup
|
||||
*/
|
||||
public $group;
|
||||
|
||||
/**
|
||||
* Create a new component group was removed event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ComponentGroup $group)
|
||||
{
|
||||
$this->group = $group;
|
||||
}
|
||||
}
|
||||
32
app/Events/Incident/IncidentWasRemovedEvent.php
Normal file
32
app/Events/Incident/IncidentWasRemovedEvent.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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\Events\Incident;
|
||||
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
|
||||
class IncidentWasRemovedEvent
|
||||
{
|
||||
/**
|
||||
* The incident that has been removed.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Incident
|
||||
*/
|
||||
public $incident;
|
||||
|
||||
/**
|
||||
* Create a new incident was removed event instance.
|
||||
*/
|
||||
public function __construct(Incident $incident)
|
||||
{
|
||||
$this->incident = $incident;
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,11 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Events;
|
||||
namespace CachetHQ\Cachet\Events\Incident;
|
||||
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
|
||||
class IncidentHasReportedEvent
|
||||
class IncidentWasReportedEvent
|
||||
{
|
||||
/**
|
||||
* The incident that has been reported.
|
||||
@@ -9,11 +9,11 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Events;
|
||||
namespace CachetHQ\Cachet\Events\Incident;
|
||||
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
|
||||
class MaintenanceHasScheduledEvent
|
||||
class MaintenanceWasScheduledEvent
|
||||
{
|
||||
/**
|
||||
* The incident that has been reported.
|
||||
34
app/Events/Metric/MetricPointWasAddedEvent.php
Normal file
34
app/Events/Metric/MetricPointWasAddedEvent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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\Events\Metric;
|
||||
|
||||
use CachetHQ\Cachet\Models\MetricPoint;
|
||||
|
||||
class MetricPointWasAddedEvent
|
||||
{
|
||||
/**
|
||||
* The metric point that was added.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\MetricPoint
|
||||
*/
|
||||
public $metric;
|
||||
|
||||
/**
|
||||
* Create a new metric point was added event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MetricPoint $metric)
|
||||
{
|
||||
$this->metric = $metric;
|
||||
}
|
||||
}
|
||||
34
app/Events/Metric/MetricPointWasRemovedEvent.php
Normal file
34
app/Events/Metric/MetricPointWasRemovedEvent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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\Events\Metric;
|
||||
|
||||
use CachetHQ\Cachet\Models\MetricPoint;
|
||||
|
||||
class MetricPointWasRemovedEvent
|
||||
{
|
||||
/**
|
||||
* The metric point that was removed.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\MetricPoint
|
||||
*/
|
||||
public $metricPoint;
|
||||
|
||||
/**
|
||||
* Create a new metric point was removed event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MetricPoint $metricPoint)
|
||||
{
|
||||
$this->metricPoint = $metricPoint;
|
||||
}
|
||||
}
|
||||
34
app/Events/Metric/MetricWasAddedEvent.php
Normal file
34
app/Events/Metric/MetricWasAddedEvent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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\Events\Metric;
|
||||
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
|
||||
class MetricWasAddedEvent
|
||||
{
|
||||
/**
|
||||
* The metric that was added.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Metric
|
||||
*/
|
||||
public $metric;
|
||||
|
||||
/**
|
||||
* Create a new metric was added event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Metric $metric)
|
||||
{
|
||||
$this->metric = $metric;
|
||||
}
|
||||
}
|
||||
34
app/Events/Metric/MetricWasRemovedEvent.php
Normal file
34
app/Events/Metric/MetricWasRemovedEvent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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\Events\Metric;
|
||||
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
|
||||
class MetricWasRemovedEvent
|
||||
{
|
||||
/**
|
||||
* The metric that was removed.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Metric
|
||||
*/
|
||||
public $metric;
|
||||
|
||||
/**
|
||||
* Create a new metric was removed event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Metric $metric)
|
||||
{
|
||||
$this->metric = $metric;
|
||||
}
|
||||
}
|
||||
32
app/Events/Subscriber/SubscriberHasSubscribedEvent.php
Normal file
32
app/Events/Subscriber/SubscriberHasSubscribedEvent.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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\Events\Subscriber;
|
||||
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
|
||||
class SubscriberHasSubscribedEvent
|
||||
{
|
||||
/**
|
||||
* The subscriber who has subscribed.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Subscriber
|
||||
*/
|
||||
public $subscriber;
|
||||
|
||||
/**
|
||||
* Create a new subscriber has subscribed event instance.
|
||||
*/
|
||||
public function __construct(Subscriber $subscriber)
|
||||
{
|
||||
$this->subscriber = $subscriber;
|
||||
}
|
||||
}
|
||||
32
app/Events/Subscriber/SubscriberHasUnsubscribedEvent.php
Normal file
32
app/Events/Subscriber/SubscriberHasUnsubscribedEvent.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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\Events\Subscriber;
|
||||
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
|
||||
class SubscriberHasUnsubscribedEvent
|
||||
{
|
||||
/**
|
||||
* The subscriber who has unsubscribed.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Subscriber
|
||||
*/
|
||||
public $subscriber;
|
||||
|
||||
/**
|
||||
* Create a new subscriber has unsubscribed event instance.
|
||||
*/
|
||||
public function __construct(Subscriber $subscriber)
|
||||
{
|
||||
$this->subscriber = $subscriber;
|
||||
}
|
||||
}
|
||||
@@ -9,21 +9,21 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Events;
|
||||
namespace CachetHQ\Cachet\Events\Subscriber;
|
||||
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
|
||||
class CustomerHasSubscribedEvent
|
||||
class SubscriberHasVerifiedEvent
|
||||
{
|
||||
/**
|
||||
* The customer who has subscribed.
|
||||
* The subscriber who has verified.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Subscriber
|
||||
*/
|
||||
public $subscriber;
|
||||
|
||||
/**
|
||||
* Create a new customer has subscribed event instance.
|
||||
* Create a new subscriber has subscribed event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
32
app/Events/User/UserWasAddedEvent.php
Normal file
32
app/Events/User/UserWasAddedEvent.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
class UserWasAddedEvent
|
||||
{
|
||||
/**
|
||||
* The user that has been added.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new user was added event instance.
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
32
app/Events/User/UserWasRemovedEvent.php
Normal file
32
app/Events/User/UserWasRemovedEvent.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
class UserWasRemovedEvent
|
||||
{
|
||||
/**
|
||||
* The user that has been removed.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new user was removed event instance.
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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\Handlers\Commands\Component;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Component\AddComponentCommand;
|
||||
use CachetHQ\Cachet\Events\Component\ComponentWasAddedEvent;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
|
||||
class AddComponentCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the add component command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\Component\AddComponentCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\Component
|
||||
*/
|
||||
public function handle(AddComponentCommand $command)
|
||||
{
|
||||
$component = Component::create([
|
||||
'name' => $command->name,
|
||||
'description' => $command->description,
|
||||
'link' => $command->link,
|
||||
'status' => $command->status,
|
||||
'order' => $command->order,
|
||||
'group_id' => $command->group_id,
|
||||
]);
|
||||
|
||||
event(new ComponentWasAddedEvent($component));
|
||||
|
||||
return $component;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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\Handlers\Commands\Component;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Component\RemoveComponentCommand;
|
||||
use CachetHQ\Cachet\Events\Component\ComponentWasRemovedEvent;
|
||||
|
||||
class RemoveComponentCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the remove component command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\Component\RemoveComponentCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(RemoveComponentCommand $command)
|
||||
{
|
||||
$component = $command->component;
|
||||
|
||||
event(new ComponentWasRemovedEvent($component));
|
||||
|
||||
$component->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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\Handlers\Commands\ComponentGroup;
|
||||
|
||||
use CachetHQ\Cachet\Commands\ComponentGroup\AddComponentGroupCommand;
|
||||
use CachetHQ\Cachet\Events\ComponentGroup\ComponentGroupWasAddedEvent;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
|
||||
class AddComponentGroupCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the add component group command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\ComponentGroup\AddComponentGroupCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\ComponentGroup
|
||||
*/
|
||||
public function handle(AddComponentGroupCommand $command)
|
||||
{
|
||||
$group = ComponentGroup::create([
|
||||
'name' => $command->name,
|
||||
'order' => $command->order,
|
||||
]);
|
||||
|
||||
event(new ComponentGroupWasAddedEvent($group));
|
||||
|
||||
return $group;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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\Handlers\Commands\ComponentGroup;
|
||||
|
||||
use CachetHQ\Cachet\Commands\ComponentGroup\RemoveComponentGroupCommand;
|
||||
use CachetHQ\Cachet\Events\ComponentGroup\ComponentGroupWasRemovedEvent;
|
||||
|
||||
class RemoveComponentGroupCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the remove component group command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\ComponentGroup\RemoveComponentGroupCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(RemoveComponentGroupCommand $command)
|
||||
{
|
||||
$group = $command->group;
|
||||
|
||||
event(new ComponentGroupWasRemovedEvent($group));
|
||||
|
||||
// Remove the group id from all component.
|
||||
$group->components->map(function ($component) {
|
||||
$component->update(['group_id' => 0]);
|
||||
});
|
||||
|
||||
$group->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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\Handlers\Commands\Incident;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Incident\RemoveIncidentCommand;
|
||||
use CachetHQ\Cachet\Events\Incident\IncidentWasRemovedEvent;
|
||||
|
||||
class RemoveIncidentCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the remove incident command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\Incident\RemoveIncidentCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(RemoveIncidentCommand $command)
|
||||
{
|
||||
$incident = $command->incident;
|
||||
|
||||
event(new IncidentWasRemovedEvent($incident));
|
||||
|
||||
$incident->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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\Handlers\Commands\Incident;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand;
|
||||
use CachetHQ\Cachet\Events\Incident\IncidentWasReportedEvent;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
|
||||
class ReportIncidentCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the report incident command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\Incident
|
||||
*/
|
||||
public function handle(ReportIncidentCommand $command)
|
||||
{
|
||||
$incident = Incident::create([
|
||||
'name' => $command->name,
|
||||
'status' => $command->status,
|
||||
'message' => $command->message,
|
||||
'visible' => $command->visible,
|
||||
'component' => $command->component_id,
|
||||
]);
|
||||
|
||||
// Update the component.
|
||||
if ($command->component_id) {
|
||||
Component::find($command->component_id)->update([
|
||||
'status' => $command->component_status,
|
||||
]);
|
||||
}
|
||||
|
||||
// Notify subscribers.
|
||||
if ($command->notify) {
|
||||
event(new IncidentWasReportedEvent($incident));
|
||||
}
|
||||
|
||||
return $incident;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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\Handlers\Commands\Incident;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Incident\ReportMaintenanceCommand;
|
||||
use CachetHQ\Cachet\Events\Incident\MaintenanceWasScheduledEvent;
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class ReportMaintenanceCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the report maintenance command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\Incident\ReportMaintenanceCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\Incident
|
||||
*/
|
||||
public function handle(ReportMaintenanceCommand $command)
|
||||
{
|
||||
// TODO: Add validation to scheduledAt
|
||||
$scheduledAt = Date::createFromFormat('d/m/Y H:i', $command->timestamp, Setting::get('app_timezone'))
|
||||
->setTimezone(Config::get('app.timezone'));
|
||||
|
||||
$maintenanceEvent = Incident::create([
|
||||
'name' => $command->name,
|
||||
'message' => $command->message,
|
||||
'scheduled_at' => $scheduledAt,
|
||||
'status' => 0,
|
||||
'visible' => 1,
|
||||
]);
|
||||
|
||||
// Notify subscribers.
|
||||
if ($command->notify) {
|
||||
event(new MaintenanceWasScheduledEvent($maintenanceEvent));
|
||||
}
|
||||
|
||||
return $maintenanceEvent;
|
||||
}
|
||||
}
|
||||
43
app/Handlers/Commands/Metric/AddMetricCommandHandler.php
Normal file
43
app/Handlers/Commands/Metric/AddMetricCommandHandler.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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\Handlers\Commands\Metric;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Metric\AddMetricCommand;
|
||||
use CachetHQ\Cachet\Events\Metric\MetricWasAddedEvent;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
|
||||
class AddMetricCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the add metric command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\Metric\AddMetricCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\Metric
|
||||
*/
|
||||
public function handle(AddMetricCommand $command)
|
||||
{
|
||||
$metric = Metric::create([
|
||||
'name' => $command->name,
|
||||
'suffix' => $command->suffix,
|
||||
'description' => $command->description,
|
||||
'default_value' => $command->default_value,
|
||||
'calc_type' => $command->calc_type,
|
||||
'display_chart' => $command->display_chart,
|
||||
'places' => $command->places,
|
||||
]);
|
||||
|
||||
event(new MetricWasAddedEvent($metric));
|
||||
|
||||
return $metric;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?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\Handlers\Commands\Metric;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Metric\AddMetricPointCommand;
|
||||
use CachetHQ\Cachet\Events\Metric\MetricPointWasAddedEvent;
|
||||
use CachetHQ\Cachet\Models\MetricPoint;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class AddMetricPointCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the add metric point command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\Metric\AddMetricPointCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\MetricPoint
|
||||
*/
|
||||
public function handle(AddMetricPointCommand $command)
|
||||
{
|
||||
$metric = $command->metric;
|
||||
$createdAt = $command->createdAt;
|
||||
|
||||
$data = [
|
||||
'metric_id' => $metric->id,
|
||||
'value' => $command->value,
|
||||
];
|
||||
|
||||
if ($createdAt) {
|
||||
$data['created_at'] = Carbon::createFromFormat('U', $createdAt)->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$metricPoint = MetricPoint::create($data);
|
||||
|
||||
event(new MetricPointWasAddedEvent($metricPoint));
|
||||
|
||||
return $metricPoint;
|
||||
}
|
||||
}
|
||||
35
app/Handlers/Commands/Metric/RemoveMetricCommandHandler.php
Normal file
35
app/Handlers/Commands/Metric/RemoveMetricCommandHandler.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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\Handlers\Commands\Metric;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Metric\RemoveMetricCommand;
|
||||
use CachetHQ\Cachet\Events\Metric\MetricWasRemovedEvent;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
|
||||
class RemoveMetricCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the remove metric command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\Metric\RemoveMetricCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(RemoveMetricCommand $command)
|
||||
{
|
||||
$metric = $command->metric;
|
||||
|
||||
event(new MetricWasRemovedEvent($metric));
|
||||
|
||||
$metric->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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\Handlers\Commands\Metric;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Metric\RemoveMetricPointCommand;
|
||||
use CachetHQ\Cachet\Events\Metric\MetricPointWasRemovedEvent;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
|
||||
class RemoveMetricPointCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the remove metric point command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\Metric\RemoveMetricPointCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(RemoveMetricPointCommand $command)
|
||||
{
|
||||
$metricPoint = $command->metricPoint;
|
||||
|
||||
event(new MetricPointWasRemovedEvent($metricPoint));
|
||||
|
||||
$metricPoint->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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\Handlers\Commands\Subscriber;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand;
|
||||
use CachetHQ\Cachet\Commands\Subscriber\VerifySubscriberCommand;
|
||||
use CachetHQ\Cachet\Events\Subscriber\SubscriberHasSubscribedEvent;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
|
||||
class SubscribeSubscriberCommandHandler
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Handle the subscribe subscriber command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\Subscriber
|
||||
*/
|
||||
public function handle(SubscribeSubscriberCommand $command)
|
||||
{
|
||||
$subscriber = Subscriber::create(['email' => $command->email]);
|
||||
|
||||
if ($command->verified) {
|
||||
$this->dispatch(new VerifySubscriberCommand($subscriber));
|
||||
} else {
|
||||
event(new SubscriberHasSubscribedEvent($subscriber));
|
||||
}
|
||||
|
||||
return $subscriber;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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\Handlers\Commands\Subscriber;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Subscriber\UnsubscribeSubscriberCommand;
|
||||
use CachetHQ\Cachet\Events\Subscriber\SubscriberHasUnsubscribedEvent;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
|
||||
class UnsubscribeSubscriberCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the subscribe customer command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\Subscriber\UnsubscribeSubscriberCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(UnsubscribeSubscriberCommand $command)
|
||||
{
|
||||
$subscriber = $command->subscriber;
|
||||
|
||||
event(new SubscriberHasUnsubscribedEvent($subscriber));
|
||||
|
||||
$subscriber->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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\Handlers\Commands\Subscriber;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Subscriber\VerifySubscriberCommand;
|
||||
use CachetHQ\Cachet\Events\Subscriber\SubscriberHasVerifiedEvent;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class VerifySubscriberCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the subscribe customer command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\Subscriber\VerifySubscriberCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(VerifySubscriberCommand $command)
|
||||
{
|
||||
$subscriber = $command->subscriber;
|
||||
|
||||
$subscriber->verified_at = Carbon::now();
|
||||
$subscriber->save();
|
||||
|
||||
event(new SubscriberHasVerifiedEvent($subscriber));
|
||||
}
|
||||
}
|
||||
40
app/Handlers/Commands/User/AddTeamMemberCommandHandler.php
Normal file
40
app/Handlers/Commands/User/AddTeamMemberCommandHandler.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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\Handlers\Commands\User;
|
||||
|
||||
use CachetHQ\Cachet\Commands\User\AddTeamMemberCommand;
|
||||
use CachetHQ\Cachet\Events\User\UserWasAddedEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
class AddTeamMemberCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the add team member command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\User\AddTeamMemberCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public function handle(AddTeamMemberCommand $command)
|
||||
{
|
||||
$user = User::create([
|
||||
'username' => $command->username,
|
||||
'password' => $command->password,
|
||||
'email' => $command->email,
|
||||
'level' => $command->level,
|
||||
]);
|
||||
|
||||
event(new UserWasAddedEvent($user));
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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\Handlers\Commands\User;
|
||||
|
||||
use CachetHQ\Cachet\Commands\User\GenerateApiTokenCommand;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
class GenerateApiTokenCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the generate api key command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\User\GenerateApiTokenCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(GenerateApiTokenCommand $command)
|
||||
{
|
||||
$user = $command->user;
|
||||
|
||||
$user->api_key = User::generateApiKey();
|
||||
$user->save();
|
||||
|
||||
//event(new GeneratedApiTokenEvent($user));
|
||||
}
|
||||
}
|
||||
35
app/Handlers/Commands/User/RemoveUserCommandHandler.php
Normal file
35
app/Handlers/Commands/User/RemoveUserCommandHandler.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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\Handlers\Commands\User;
|
||||
|
||||
use CachetHQ\Cachet\Commands\User\RemoveUserCommand;
|
||||
use CachetHQ\Cachet\Events\User\UserWasRemovedEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
class RemoveUserCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the remove user command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Commands\User\RemoveUserCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(RemoveUserCommand $command)
|
||||
{
|
||||
$user = $command->user;
|
||||
|
||||
event(new UserWasRemovedEvent($user));
|
||||
|
||||
$user->delete();
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,9 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Handlers\Events;
|
||||
namespace CachetHQ\Cachet\Handlers\Events\Incident;
|
||||
|
||||
use CachetHQ\Cachet\Events\IncidentHasReportedEvent;
|
||||
use CachetHQ\Cachet\Events\Incident\IncidentWasReportedEvent;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use Illuminate\Contracts\Mail\MailQueue;
|
||||
use Illuminate\Mail\Message;
|
||||
@@ -59,11 +59,11 @@ class SendIncidentEmailNotificationHandler
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Events\IncidentHasReportedEvent $event
|
||||
* @param \CachetHQ\Cachet\Events\Incident\IncidentHasReportedEvent $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(IncidentHasReportedEvent $event)
|
||||
public function handle(IncidentWasReportedEvent $event)
|
||||
{
|
||||
$incident = $this->presenter->decorate($event->incident);
|
||||
$component = $this->presenter->decorate($event->incident->component);
|
||||
@@ -75,7 +75,7 @@ class SendIncidentEmailNotificationHandler
|
||||
'email' => $subscriber->email,
|
||||
'subject' => 'New incident reported.',
|
||||
'has_component' => ($event->incident->component) ? true : false,
|
||||
'component_name' => $component->name,
|
||||
'component_name' => $component ? $component->name : null,
|
||||
'status' => $incident->humanStatus,
|
||||
'html_content' => $incident->formattedMessage,
|
||||
'text_content' => $incident->message,
|
||||
@@ -9,9 +9,9 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Handlers\Events;
|
||||
namespace CachetHQ\Cachet\Handlers\Events\Incident;
|
||||
|
||||
use CachetHQ\Cachet\Events\MaintenanceHasScheduledEvent;
|
||||
use CachetHQ\Cachet\Events\Incident\MaintenanceWasScheduledEvent;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use Illuminate\Contracts\Mail\MailQueue;
|
||||
use Illuminate\Mail\Message;
|
||||
@@ -63,7 +63,7 @@ class SendMaintenanceEmailNotificationHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(MaintenanceHasScheduledEvent $event)
|
||||
public function handle(MaintenanceWasScheduledEvent $event)
|
||||
{
|
||||
$data = $this->presenter->decorate($event->incident);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Handlers\Events;
|
||||
|
||||
use CachetHQ\Cachet\Events\CustomerHasSubscribedEvent;
|
||||
use CachetHQ\Cachet\Events\SubscriberHasSubscribedEvent;
|
||||
use Illuminate\Contracts\Mail\MailQueue;
|
||||
use Illuminate\Mail\Message;
|
||||
|
||||
@@ -43,7 +43,7 @@ class SendSubscriberVerificationEmailHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(CustomerHasSubscribedEvent $event)
|
||||
public function handle(SubscriberHasSubscribedEvent $event)
|
||||
{
|
||||
$mail = [
|
||||
'email' => $event->subscriber->email,
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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\Handlers\Events\Subscriber;
|
||||
|
||||
use CachetHQ\Cachet\Events\SubscriberHasSubscribedEvent;
|
||||
use Illuminate\Contracts\Mail\MailQueue;
|
||||
use Illuminate\Mail\Message;
|
||||
|
||||
class SendSubscriberVerificationEmailHandler
|
||||
{
|
||||
/**
|
||||
* The mailer instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Mail\MailQueue
|
||||
*/
|
||||
protected $mailer;
|
||||
|
||||
/**
|
||||
* Create a new send subscriber verification email handler.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Mail\Mailer $mailer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MailQueue $mailer)
|
||||
{
|
||||
$this->mailer = $mailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Events\CustomerHasSubscribedEvent $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(SubscriberHasSubscribedEvent $event)
|
||||
{
|
||||
$mail = [
|
||||
'email' => $event->subscriber->email,
|
||||
'subject' => 'Confirm your subscription.',
|
||||
'link' => route('subscribe.verify', ['code' => $event->subscriber->verify_code]),
|
||||
'app_url' => env('APP_URL'),
|
||||
];
|
||||
|
||||
$this->mailer->queue([
|
||||
'html' => 'emails.subscribers.verify-html',
|
||||
'text' => 'emails.subscribers.verify-text',
|
||||
], $mail, function (Message $message) use ($mail) {
|
||||
$message->to($mail['email'])->subject($mail['subject']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -11,16 +11,21 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Component\AddComponentCommand;
|
||||
use CachetHQ\Cachet\Commands\Component\RemoveComponentCommand;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class ComponentController extends AbstractApiController
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Get all components.
|
||||
*
|
||||
@@ -56,10 +61,15 @@ class ComponentController extends AbstractApiController
|
||||
*/
|
||||
public function postComponents(Guard $auth)
|
||||
{
|
||||
$componentData = Binput::except('tags');
|
||||
|
||||
try {
|
||||
$component = Component::create($componentData);
|
||||
$component = $this->dispatch(new AddComponentCommand(
|
||||
Binput::get('name'),
|
||||
Binput::get('description'),
|
||||
Binput::get('status'),
|
||||
Binput::get('link'),
|
||||
Binput::get('order'),
|
||||
Binput::get('group_id')
|
||||
));
|
||||
} catch (Exception $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
@@ -119,7 +129,7 @@ class ComponentController extends AbstractApiController
|
||||
*/
|
||||
public function deleteComponent(Component $component)
|
||||
{
|
||||
$component->delete();
|
||||
$this->dispatch(new RemoveComponentCommand($component));
|
||||
|
||||
return $this->noContent();
|
||||
}
|
||||
|
||||
@@ -11,14 +11,19 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Commands\ComponentGroup\AddComponentGroupCommand;
|
||||
use CachetHQ\Cachet\Commands\ComponentGroup\RemoveComponentGroupCommand;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class ComponentGroupController extends AbstractApiController
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Get all groups.
|
||||
*
|
||||
@@ -52,10 +57,11 @@ class ComponentGroupController extends AbstractApiController
|
||||
*/
|
||||
public function postGroups()
|
||||
{
|
||||
$groupData = array_filter(Binput::only(['name', 'order']));
|
||||
|
||||
try {
|
||||
$group = ComponentGroup::create($groupData);
|
||||
$group = $this->dispatch(new AddComponentGroupCommand(
|
||||
Binput::get('name'),
|
||||
Binput::get('order', 0)
|
||||
));
|
||||
} catch (Exception $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
@@ -77,7 +83,6 @@ class ComponentGroupController extends AbstractApiController
|
||||
try {
|
||||
$group->update($groupData);
|
||||
} catch (Exception $e) {
|
||||
dd($e->getMessage());
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
@@ -93,7 +98,7 @@ class ComponentGroupController extends AbstractApiController
|
||||
*/
|
||||
public function deleteGroup(ComponentGroup $group)
|
||||
{
|
||||
$group->delete();
|
||||
$this->dispatch(new RemoveComponentGroupCommand($group));
|
||||
|
||||
return $this->noContent();
|
||||
}
|
||||
|
||||
@@ -11,16 +11,20 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Events\IncidentHasReportedEvent;
|
||||
use CachetHQ\Cachet\Commands\Incident\RemoveIncidentCommand;
|
||||
use CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class IncidentController extends AbstractApiController
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Get all incidents.
|
||||
*
|
||||
@@ -59,30 +63,20 @@ class IncidentController extends AbstractApiController
|
||||
*/
|
||||
public function postIncidents(Guard $auth)
|
||||
{
|
||||
$incidentData = array_filter(Binput::only([
|
||||
'name',
|
||||
'message',
|
||||
'status',
|
||||
'component_id',
|
||||
'notify',
|
||||
'visible',
|
||||
]));
|
||||
|
||||
// Default visibility is 1.
|
||||
if (!array_has($incidentData, 'visible')) {
|
||||
$incidentData['visible'] = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
$incident = Incident::create($incidentData);
|
||||
$incident = $this->dispatch(new ReportIncidentCommand(
|
||||
Binput::get('name'),
|
||||
Binput::get('status'),
|
||||
Binput::get('message'),
|
||||
Binput::get('visible', true),
|
||||
Binput::get('component_id'),
|
||||
Binput::get('component_status'),
|
||||
Binput::get('notify', true)
|
||||
));
|
||||
} catch (Exception $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
if (array_get($incidentData, 'notify') && subscribers_enabled()) {
|
||||
event(new IncidentHasReportedEvent($incident));
|
||||
}
|
||||
|
||||
return $this->item($incident);
|
||||
}
|
||||
|
||||
@@ -122,7 +116,7 @@ class IncidentController extends AbstractApiController
|
||||
*/
|
||||
public function deleteIncident(Incident $incident)
|
||||
{
|
||||
$incident->delete();
|
||||
$this->dispatch(new RemoveIncidentCommand($incident));
|
||||
|
||||
return $this->noContent();
|
||||
}
|
||||
|
||||
@@ -11,14 +11,19 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Metric\AddMetricCommand;
|
||||
use CachetHQ\Cachet\Commands\Metric\RemoveMetricCommand;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class MetricController extends AbstractApiController
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Get all metrics.
|
||||
*
|
||||
@@ -65,7 +70,15 @@ class MetricController extends AbstractApiController
|
||||
public function postMetrics()
|
||||
{
|
||||
try {
|
||||
$metric = Metric::create(Binput::all());
|
||||
$metric = $this->dispatch(new AddMetricCommand(
|
||||
Binput::get('name'),
|
||||
Binput::get('suffix'),
|
||||
Binput::get('description'),
|
||||
Binput::get('default_value'),
|
||||
Binput::get('calc_type', 0),
|
||||
Binput::get('display_chart'),
|
||||
Binput::get('places')
|
||||
));
|
||||
} catch (Exception $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
@@ -100,7 +113,7 @@ class MetricController extends AbstractApiController
|
||||
*/
|
||||
public function deleteMetric(Metric $metric)
|
||||
{
|
||||
$metric->delete();
|
||||
$this->dispatch(new RemoveMetricCommand($metric));
|
||||
|
||||
return $this->noContent();
|
||||
}
|
||||
|
||||
@@ -11,14 +11,20 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Commands\Metric\AddMetricPointCommand;
|
||||
use CachetHQ\Cachet\Commands\Metric\RemoveMetricPointCommand;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use CachetHQ\Cachet\Models\MetricPoint;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class MetricPointController extends AbstractApiController
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Get a single metric point.
|
||||
*
|
||||
@@ -41,16 +47,8 @@ class MetricPointController extends AbstractApiController
|
||||
*/
|
||||
public function postMetricPoints(Metric $metric)
|
||||
{
|
||||
$metricPointData = Binput::all();
|
||||
$metricPointData['metric_id'] = $metric->id;
|
||||
|
||||
if ($timestamp = array_pull($metricPointData, 'timestamp')) {
|
||||
$pointTimestamp = Carbon::createFromFormat('U', $timestamp);
|
||||
$metricPointData['created_at'] = $pointTimestamp->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
try {
|
||||
$metricPoint = MetricPoint::create($metricPointData);
|
||||
$metricPoint = $this->dispatch(new AddMetricPointCommand($metric, Binput::get('value'), Binput::get('timestamp')));
|
||||
} catch (Exception $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
@@ -91,7 +89,7 @@ class MetricPointController extends AbstractApiController
|
||||
*/
|
||||
public function deleteMetricPoint(Metric $metric, MetricPoint $metricPoint)
|
||||
{
|
||||
$metricPoint->delete();
|
||||
$this->dispatch(new RemoveMetricPointCommand($metricPoint));
|
||||
|
||||
return $this->noContent();
|
||||
}
|
||||
|
||||
@@ -11,15 +11,19 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Events\CustomerHasSubscribedEvent;
|
||||
use CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand;
|
||||
use CachetHQ\Cachet\Commands\Subscriber\UnsubscribeSubscriberCommand;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class SubscriberController extends AbstractApiController
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Get all subscribers.
|
||||
*
|
||||
@@ -41,19 +45,12 @@ class SubscriberController extends AbstractApiController
|
||||
*/
|
||||
public function postSubscribers()
|
||||
{
|
||||
$subscriberData = Binput::except('verify');
|
||||
|
||||
try {
|
||||
$subscriber = Subscriber::create($subscriberData);
|
||||
$subscriber = $this->dispatch(new SubscribeSubscriberCommand(Binput::get('email'), Binput::get('verify', false)));
|
||||
} catch (Exception $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
// If we're auto-verifying the subscriber, don't bother with this event.
|
||||
if (!(Binput::get('verify'))) {
|
||||
event(new CustomerHasSubscribedEvent($subscriber));
|
||||
}
|
||||
|
||||
return $this->item($subscriber);
|
||||
}
|
||||
|
||||
@@ -66,7 +63,7 @@ class SubscriberController extends AbstractApiController
|
||||
*/
|
||||
public function deleteSubscriber(Subscriber $subscriber)
|
||||
{
|
||||
$subscriber->delete();
|
||||
$this->dispatch(new UnsubscribeSubscriberCommand($subscriber));
|
||||
|
||||
return $this->noContent();
|
||||
}
|
||||
|
||||
@@ -12,16 +12,23 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Commands\Component\AddComponentCommand;
|
||||
use CachetHQ\Cachet\Commands\Component\RemoveComponentCommand;
|
||||
use CachetHQ\Cachet\Commands\ComponentGroup\AddComponentGroupCommand;
|
||||
use CachetHQ\Cachet\Commands\ComponentGroup\RemoveComponentGroupCommand;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class ComponentController extends Controller
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
protected $subMenu = [];
|
||||
|
||||
public function __construct()
|
||||
@@ -157,7 +164,7 @@ class ComponentController extends Controller
|
||||
$tags = array_pull($_component, 'tags');
|
||||
|
||||
try {
|
||||
$component = Component::create($_component);
|
||||
$component = $this->dispatchFromArray(AddComponentCommand::class, Binput::get('component'));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('dashboard.components.add')
|
||||
->withInput(Binput::all())
|
||||
@@ -188,7 +195,7 @@ class ComponentController extends Controller
|
||||
*/
|
||||
public function deleteComponentAction(Component $component)
|
||||
{
|
||||
$component->delete();
|
||||
$this->dispatch(new RemoveComponentCommand($component));
|
||||
|
||||
return Redirect::route('dashboard.components.index');
|
||||
}
|
||||
@@ -202,11 +209,7 @@ class ComponentController extends Controller
|
||||
*/
|
||||
public function deleteComponentGroupAction(ComponentGroup $group)
|
||||
{
|
||||
$group->components->map(function ($component) {
|
||||
$component->update(['group_id' => 0]);
|
||||
});
|
||||
|
||||
$group->delete();
|
||||
$this->dispatch(new RemoveComponentGroupCommand($group));
|
||||
|
||||
return Redirect::route('dashboard.components.index');
|
||||
}
|
||||
@@ -244,7 +247,10 @@ class ComponentController extends Controller
|
||||
public function postAddComponentGroup()
|
||||
{
|
||||
try {
|
||||
$group = ComponentGroup::create(Binput::get('group'));
|
||||
$group = $this->dispatch(new AddComponentGroupCommand(
|
||||
Binput::get('name'),
|
||||
Binput::get('order', 0)
|
||||
));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('dashboard.components.groups.add')
|
||||
->withInput(Binput::all())
|
||||
|
||||
@@ -12,13 +12,15 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Events\IncidentHasReportedEvent;
|
||||
use CachetHQ\Cachet\Commands\Incident\RemoveIncidentCommand;
|
||||
use CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand;
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\IncidentTemplate;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
@@ -27,6 +29,8 @@ use Jenssegers\Date\Date;
|
||||
|
||||
class IncidentController extends Controller
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Stores the sub-sidebar tree list.
|
||||
*
|
||||
@@ -107,19 +111,25 @@ class IncidentController extends Controller
|
||||
*/
|
||||
public function createIncidentAction()
|
||||
{
|
||||
$incidentData = Binput::get('incident');
|
||||
$componentStatus = array_pull($incidentData, 'component_status');
|
||||
|
||||
if (array_has($incidentData, 'created_at') && $incidentData['created_at']) {
|
||||
$incidentDate = Date::createFromFormat('d/m/Y H:i', $incidentData['created_at'], Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone'));
|
||||
$incidentData['created_at'] = $incidentDate;
|
||||
$incidentData['updated_at'] = $incidentDate;
|
||||
} else {
|
||||
unset($incidentData['created_at']);
|
||||
if ($createdAt = Binput::get('created_at')) {
|
||||
$incidentDate = Date::createFromFormat('d/m/Y H:i', $createdAt, Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone'));
|
||||
}
|
||||
|
||||
try {
|
||||
$incident = Incident::create($incidentData);
|
||||
$incident = $this->dispatch(new ReportIncidentCommand(
|
||||
Binput::get('name'),
|
||||
Binput::get('status'),
|
||||
Binput::get('message'),
|
||||
Binput::get('visible', true),
|
||||
Binput::get('component_id'),
|
||||
Binput::get('component_status'),
|
||||
Binput::get('notify', true)
|
||||
));
|
||||
|
||||
$incident->update([
|
||||
'created_at' => $incidentDate,
|
||||
'updated_at' => $incidentDate,
|
||||
]);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('dashboard.incidents.add')
|
||||
->withInput(Binput::all())
|
||||
@@ -127,15 +137,6 @@ class IncidentController extends Controller
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
// Update the component.
|
||||
if (isset($incidentData['component_id']) && (int) $incidentData['component_id'] > 0) {
|
||||
Component::find($incidentData['component_id'])->update(['status' => $componentStatus]);
|
||||
}
|
||||
|
||||
if (array_get($incidentData, 'notify') && subscribers_enabled()) {
|
||||
event(new IncidentHasReportedEvent($incident));
|
||||
}
|
||||
|
||||
return Redirect::route('dashboard.incidents.add')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success')));
|
||||
}
|
||||
@@ -208,7 +209,7 @@ class IncidentController extends Controller
|
||||
*/
|
||||
public function deleteIncidentAction(Incident $incident)
|
||||
{
|
||||
$incident->delete();
|
||||
$this->dispatch(new RemoveIncidentCommand($incident));
|
||||
|
||||
return Redirect::route('dashboard.incidents.index');
|
||||
}
|
||||
|
||||
@@ -12,15 +12,20 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Commands\Metric\AddMetricCommand;
|
||||
use CachetHQ\Cachet\Commands\Metric\RemoveMetricCommand;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use CachetHQ\Cachet\Models\MetricPoint;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class MetricController extends Controller
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Shows the metrics view.
|
||||
*
|
||||
@@ -66,7 +71,7 @@ class MetricController extends Controller
|
||||
public function createMetricAction()
|
||||
{
|
||||
try {
|
||||
Metric::create(Binput::get('metric'));
|
||||
$this->dispatchFromArray(AddMetricCommand::class, Binput::get('metric'));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('dashboard.metrics.add')
|
||||
->withInput(Binput::all())
|
||||
@@ -98,7 +103,7 @@ class MetricController extends Controller
|
||||
*/
|
||||
public function deleteMetricAction(Metric $metric)
|
||||
{
|
||||
$metric->delete();
|
||||
$this->dispatch(new RemoveMetricCommand($metric));
|
||||
|
||||
return Redirect::route('dashboard.metrics.index');
|
||||
}
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Events\MaintenanceHasScheduledEvent;
|
||||
use CachetHQ\Cachet\Commands\Incident\ReportMaintenanceCommand;
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\IncidentTemplate;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
@@ -26,6 +27,8 @@ use Jenssegers\Date\Date;
|
||||
|
||||
class ScheduleController extends Controller
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Stores the sub-sidebar tree list.
|
||||
*
|
||||
@@ -92,24 +95,13 @@ class ScheduleController extends Controller
|
||||
*/
|
||||
public function addScheduleAction()
|
||||
{
|
||||
$scheduleData = Binput::get('incident');
|
||||
// Parse the schedule date.
|
||||
$scheduledAt = Date::createFromFormat('d/m/Y H:i', $scheduleData['scheduled_at'], Setting::get('app_timezone'))
|
||||
->setTimezone(Config::get('app.timezone'));
|
||||
|
||||
if ($scheduledAt->isPast()) {
|
||||
$messageBag = new MessageBag();
|
||||
$messageBag->add('scheduled_at', trans('validation.date', ['attribute' => 'scheduled time you supplied']));
|
||||
|
||||
return Redirect::route('dashboard.schedule.add')->withErrors($messageBag);
|
||||
}
|
||||
|
||||
$scheduleData['scheduled_at'] = $scheduledAt;
|
||||
// Bypass the incident.status field.
|
||||
$scheduleData['status'] = 0;
|
||||
|
||||
try {
|
||||
$incident = Incident::create($scheduleData);
|
||||
$incident = $this->dispatch(new ReportMaintenanceCommand(
|
||||
Binput::get('incident.name'),
|
||||
Binput::get('incident.message'),
|
||||
Binput::get('incident.notify'),
|
||||
Binput::get('incident.scheduled_at')
|
||||
));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('dashboard.schedule.add')
|
||||
->withInput(Binput::all())
|
||||
@@ -117,10 +109,6 @@ class ScheduleController extends Controller
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
if (array_get($scheduleData, 'notify') && subscribers_enabled()) {
|
||||
event(new MaintenanceHasScheduledEvent($incident));
|
||||
}
|
||||
|
||||
return Redirect::route('dashboard.schedule.add')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.add.success')));
|
||||
}
|
||||
|
||||
@@ -12,15 +12,19 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Events\CustomerHasSubscribedEvent;
|
||||
use CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand;
|
||||
use CachetHQ\Cachet\Commands\Subscriber\UnsubscribeSubscriberCommand;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class SubscriberController extends Controller
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Shows the subscribers view.
|
||||
*
|
||||
@@ -53,10 +57,8 @@ class SubscriberController extends Controller
|
||||
*/
|
||||
public function createSubscriberAction()
|
||||
{
|
||||
$email = Binput::get('email');
|
||||
|
||||
try {
|
||||
$subscriber = Subscriber::create(['email' => $email]);
|
||||
$this->dispatch(new SubscribeSubscriberCommand(Binput::get('email')));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('dashboard.subscribers.add')
|
||||
->withInput(Binput::all())
|
||||
@@ -64,8 +66,6 @@ class SubscriberController extends Controller
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
event(new CustomerHasSubscribedEvent($subscriber));
|
||||
|
||||
return Redirect::route('dashboard.subscribers.add')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')));
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class SubscriberController extends Controller
|
||||
*/
|
||||
public function deleteSubscriberAction(Subscriber $subscriber)
|
||||
{
|
||||
$subscriber->delete();
|
||||
$this->dispatch(new UnsubscribeSubscriberCommand($subscriber));
|
||||
|
||||
return Redirect::route('dashboard.subscribers.index');
|
||||
}
|
||||
|
||||
@@ -12,14 +12,19 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Commands\User\AddTeamMemberCommand;
|
||||
use CachetHQ\Cachet\Commands\User\RemoveUserCommand;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class TeamController extends Controller
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Shows the team members view.
|
||||
*
|
||||
@@ -65,7 +70,12 @@ class TeamController extends Controller
|
||||
public function postAddUser()
|
||||
{
|
||||
try {
|
||||
User::create(Binput::all());
|
||||
$this->dispatch(new AddTeamMemberCommand(
|
||||
Binput::get('username'),
|
||||
Binput::get('password'),
|
||||
Binput::get('email'),
|
||||
Binput::get('level')
|
||||
));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('dashboard.team.add')
|
||||
->withInput(Binput::except('password'))
|
||||
@@ -86,19 +96,18 @@ class TeamController extends Controller
|
||||
*/
|
||||
public function postUpdateUser(User $user)
|
||||
{
|
||||
$items = Binput::all();
|
||||
|
||||
$passwordChange = array_get($items, 'password');
|
||||
|
||||
if (trim($passwordChange) === '') {
|
||||
unset($items['password']);
|
||||
}
|
||||
$userData = array_filter(Binput::only([
|
||||
'username',
|
||||
'email',
|
||||
'password',
|
||||
'level',
|
||||
]));
|
||||
|
||||
try {
|
||||
$user->update($items);
|
||||
$user->update($userData);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('dashboard.team.edit', ['id' => $user->id])
|
||||
->withInput(Binput::except('password'))
|
||||
->withInput($userData)
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
@@ -116,7 +125,7 @@ class TeamController extends Controller
|
||||
*/
|
||||
public function deleteUser(User $user)
|
||||
{
|
||||
$user->delete();
|
||||
$this->dispatch(new RemoveUserCommand($user));
|
||||
|
||||
return Redirect::route('dashboard.team.index')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.delete.success')));
|
||||
|
||||
@@ -40,27 +40,27 @@ class UserController extends Controller
|
||||
*/
|
||||
public function postUser()
|
||||
{
|
||||
$items = Binput::all();
|
||||
$userData = array_filter(Binput::only([
|
||||
'username',
|
||||
'email',
|
||||
'password',
|
||||
'google2fa',
|
||||
]));
|
||||
|
||||
$passwordChange = array_get($items, 'password');
|
||||
$enable2FA = (bool) array_pull($items, 'google2fa');
|
||||
$enable2FA = (bool) array_pull($userData, 'google2fa');
|
||||
|
||||
// Let's enable/disable auth
|
||||
if ($enable2FA && !Auth::user()->hasTwoFactor) {
|
||||
$items['google_2fa_secret'] = Google2FA::generateSecretKey();
|
||||
$userData['google_2fa_secret'] = Google2FA::generateSecretKey();
|
||||
} elseif (!$enable2FA) {
|
||||
$items['google_2fa_secret'] = '';
|
||||
}
|
||||
|
||||
if (trim($passwordChange) === '') {
|
||||
unset($items['password']);
|
||||
$userData['google_2fa_secret'] = '';
|
||||
}
|
||||
|
||||
try {
|
||||
Auth::user()->update($items);
|
||||
Auth::user()->update($userData);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('dashboard.user')
|
||||
->withInput(Binput::except('password'))
|
||||
->withInput($userData)
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
@@ -12,19 +12,24 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Events\CustomerHasSubscribedEvent;
|
||||
use CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand;
|
||||
use CachetHQ\Cachet\Commands\Subscriber\UnsubscribeSubscriberCommand;
|
||||
use CachetHQ\Cachet\Commands\Subscriber\VerifySubscriberCommand;
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use Carbon\Carbon;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use GrahamCampbell\Markdown\Facades\Markdown;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class SubscribeController extends Controller
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Show the subscribe by email page.
|
||||
*
|
||||
@@ -45,7 +50,7 @@ class SubscribeController extends Controller
|
||||
public function postSubscribe()
|
||||
{
|
||||
try {
|
||||
$subscriber = Subscriber::create(['email' => Binput::get('email')]);
|
||||
$this->dispatch(new SubscribeSubscriberCommand(Binput::get('email')));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('subscribe.subscribe')
|
||||
->withInput(Binput::all())
|
||||
@@ -53,8 +58,6 @@ class SubscribeController extends Controller
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
event(new CustomerHasSubscribedEvent($subscriber));
|
||||
|
||||
return Redirect::route('status-page')
|
||||
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed')));
|
||||
}
|
||||
@@ -75,11 +78,10 @@ class SubscribeController extends Controller
|
||||
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
|
||||
|
||||
if (!$subscriber || $subscriber->verified()) {
|
||||
return Redirect::route('status-page');
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
$subscriber->verified_at = Carbon::now();
|
||||
$subscriber->save();
|
||||
$this->dispatch(new VerifySubscriberCommand($subscriber));
|
||||
|
||||
return Redirect::route('status-page')
|
||||
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.verified')));
|
||||
@@ -101,10 +103,10 @@ class SubscribeController extends Controller
|
||||
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
|
||||
|
||||
if (!$subscriber || !$subscriber->verified()) {
|
||||
return Redirect::route('status-page');
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
$subscriber->delete();
|
||||
$this->dispatch(new UnsubscribeSubscriberCommand($subscriber));
|
||||
|
||||
return Redirect::route('status-page')
|
||||
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.unsuscribed')));
|
||||
|
||||
@@ -42,7 +42,7 @@ class ComponentGroup extends Model
|
||||
* @var string[]
|
||||
*/
|
||||
public $rules = [
|
||||
'name' => 'required',
|
||||
'name' => 'required|string',
|
||||
'order' => 'integer',
|
||||
];
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function boot(Dispatcher $dispatcher)
|
||||
{
|
||||
$dispatcher->mapUsing(function ($command) {
|
||||
return Dispatcher::simpleMapping($command, 'CachetHQ\Cachet\Commands', 'CachetHQ\Cachet\Handlers\Commands');
|
||||
return Dispatcher::simpleMapping($command, 'CachetHQ\Cachet', 'CachetHQ\Cachet\Handlers');
|
||||
});
|
||||
|
||||
Str::macro('canonicalize', function ($url) {
|
||||
|
||||
@@ -21,14 +21,14 @@ class EventServiceProvider extends ServiceProvider
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'CachetHQ\Cachet\Events\CustomerHasSubscribedEvent' => [
|
||||
'CachetHQ\Cachet\Events\Subscriber\SubscriberHasSubscribedEvent' => [
|
||||
'CachetHQ\Cachet\Handlers\Events\SendSubscriberVerificationEmailHandler',
|
||||
],
|
||||
'CachetHQ\Cachet\Events\IncidentHasReportedEvent' => [
|
||||
'CachetHQ\Cachet\Handlers\Events\SendIncidentEmailNotificationHandler',
|
||||
'CachetHQ\Cachet\Events\Incident\IncidentWasReportedEvent' => [
|
||||
'CachetHQ\Cachet\Handlers\Events\Incident\SendIncidentEmailNotificationHandler',
|
||||
],
|
||||
'CachetHQ\Cachet\Events\MaintenanceHasScheduledEvent' => [
|
||||
'CachetHQ\Cachet\Handlers\Events\SendMaintenanceEmailNotificationHandler',
|
||||
'CachetHQ\Cachet\Events\Incident\MaintenanceWasScheduledEvent' => [
|
||||
'CachetHQ\Cachet\Handlers\Events\Incident\SendMaintenanceEmailNotificationHandler',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label for="incident-name">{{ trans('forms.components.groups.name') }}</label>
|
||||
<input type="text" class="form-control" name="group[name]" id="group-name" required>
|
||||
<input type="text" class="form-control" name="name" id="group-name" required>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
|
||||
@@ -30,34 +30,34 @@
|
||||
@endif
|
||||
<div class="form-group">
|
||||
<label for="incident-name">{{ trans('forms.incidents.name') }}</label>
|
||||
<input type="text" class="form-control" name="incident[name]" id="incident-name" required value="{{ Input::old('incident.name') }}">
|
||||
<input type="text" class="form-control" name="name" id="incident-name" required value="{{ Input::old('incident.name') }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="incident-name">{{ trans('forms.incidents.status') }}</label><br>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="incident[status]" value="1">
|
||||
<input type="radio" name="status" value="1">
|
||||
<i class="icon ion-flag"></i>
|
||||
{{ trans('cachet.incidents.status')[1] }}
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="incident[status]" value="2">
|
||||
<input type="radio" name="status" value="2">
|
||||
<i class="icon ion-alert-circled"></i>
|
||||
{{ trans('cachet.incidents.status')[2] }}
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="incident[status]" value="3">
|
||||
<input type="radio" name="status" value="3">
|
||||
<i class="icon ion-eye"></i>
|
||||
{{ trans('cachet.incidents.status')[3] }}
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="incident[status]" value="4">
|
||||
<input type="radio" name="status" value="4">
|
||||
<i class="icon ion-checkmark"></i>
|
||||
{{ trans('cachet.incidents.status')[4] }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="incident-name">{{ trans('forms.incidents.visibility') }}</label>
|
||||
<select name='incident[visible]' class="form-control">
|
||||
<select name='visible' class="form-control">
|
||||
<option value='1' selected>{{ trans('forms.incidents.public') }}</option>
|
||||
<option value='0'>{{ trans('forms.incidents.logged_in_only') }}</option>
|
||||
</select>
|
||||
@@ -65,7 +65,7 @@
|
||||
@if(!$components_in_groups->isEmpty() || !$components_out_groups->isEmpty())
|
||||
<div class="form-group">
|
||||
<label>{{ trans('forms.incidents.component') }}</label>
|
||||
<select name='incident[component_id]' class='form-control'>
|
||||
<select name='component_id' class='form-control'>
|
||||
<option value='0' selected></option>
|
||||
@foreach($components_in_groups as $group)
|
||||
<optgroup label="{{ $group->name }}">
|
||||
@@ -88,7 +88,7 @@
|
||||
@foreach(trans('cachet.components.status') as $statusID => $status)
|
||||
<div class="radio-inline">
|
||||
<label>
|
||||
<input type="radio" name="incident[component_status]" value="{{ $statusID }}">
|
||||
<input type="radio" name="component_status" value="{{ $statusID }}">
|
||||
{{ $status }}
|
||||
</label>
|
||||
</div>
|
||||
@@ -100,17 +100,17 @@
|
||||
<div class="form-group">
|
||||
<label>{{ trans('forms.incidents.message') }}</label>
|
||||
<div class='markdown-control'>
|
||||
<textarea name="incident[message]" class="form-control autosize" rows="5" required>{{ Input::old('incident.message') }}</textarea>
|
||||
<textarea name="message" class="form-control autosize" rows="5" required>{{ Input::old('incident.message') }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{ trans('forms.incidents.incident_time') }}</label>
|
||||
<input type="text" name="incident[created_at]" class="form-control" rel="datepicker-any">
|
||||
<input type="text" name="created_at" class="form-control" rel="datepicker-any">
|
||||
<span class="help-block">{{ trans('forms.optional') }}</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{ trans('forms.incidents.notify_subscribers') }}</label>
|
||||
<input type="checkbox" name="incident[notify]" value="1" checked="{{ Input::old('incident.message', 'checked') }}">
|
||||
<input type="checkbox" name="notify" value="1" checked="{{ Input::old('incident.message', 'checked') }}">
|
||||
<span class="help-block">{{ trans('forms.optional') }}</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -59,6 +59,7 @@ class MetricTest extends AbstractTestCase
|
||||
'description' => 'Lorem ipsum dolor',
|
||||
'default_value' => 1,
|
||||
'display_chart' => 1,
|
||||
'places' => 0,
|
||||
]);
|
||||
$this->seeJson(['name' => 'Foo']);
|
||||
$this->assertResponseOk();
|
||||
|
||||
@@ -40,7 +40,7 @@ class SubscriberTest extends AbstractTestCase
|
||||
{
|
||||
$this->beUser();
|
||||
|
||||
$this->expectsEvents('CachetHQ\Cachet\Events\CustomerHasSubscribedEvent');
|
||||
$this->expectsEvents('CachetHQ\Cachet\Events\Subscriber\SubscriberHasSubscribedEvent');
|
||||
|
||||
$this->post('/api/v1/subscribers', [
|
||||
'email' => 'james@cachethq.io',
|
||||
|
||||
Reference in New Issue
Block a user