id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
220,700
|
Seldaek/monolog
|
src/Monolog/Handler/ProcessHandler.php
|
ProcessHandler.handleStartupErrors
|
private function handleStartupErrors(): void
{
$selected = $this->selectErrorStream();
if (false === $selected) {
throw new \UnexpectedValueException('Something went wrong while selecting a stream.');
}
$errors = $this->readProcessErrors();
if (is_resource($this->process) === false || empty($errors) === false) {
throw new \UnexpectedValueException(
sprintf('The process "%s" could not be opened: ' . $errors, $this->command)
);
}
}
|
php
|
private function handleStartupErrors(): void
{
$selected = $this->selectErrorStream();
if (false === $selected) {
throw new \UnexpectedValueException('Something went wrong while selecting a stream.');
}
$errors = $this->readProcessErrors();
if (is_resource($this->process) === false || empty($errors) === false) {
throw new \UnexpectedValueException(
sprintf('The process "%s" could not be opened: ' . $errors, $this->command)
);
}
}
|
[
"private",
"function",
"handleStartupErrors",
"(",
")",
":",
"void",
"{",
"$",
"selected",
"=",
"$",
"this",
"->",
"selectErrorStream",
"(",
")",
";",
"if",
"(",
"false",
"===",
"$",
"selected",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Something went wrong while selecting a stream.'",
")",
";",
"}",
"$",
"errors",
"=",
"$",
"this",
"->",
"readProcessErrors",
"(",
")",
";",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"process",
")",
"===",
"false",
"||",
"empty",
"(",
"$",
"errors",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"sprintf",
"(",
"'The process \"%s\" could not be opened: '",
".",
"$",
"errors",
",",
"$",
"this",
"->",
"command",
")",
")",
";",
"}",
"}"
] |
Selects the STDERR stream, handles upcoming startup errors, and throws an exception, if any.
@throws \UnexpectedValueException
|
[
"Selects",
"the",
"STDERR",
"stream",
"handles",
"upcoming",
"startup",
"errors",
"and",
"throws",
"an",
"exception",
"if",
"any",
"."
] |
ebb804e432e8fe0fe96828f30d89c45581d36d07
|
https://github.com/Seldaek/monolog/blob/ebb804e432e8fe0fe96828f30d89c45581d36d07/src/Monolog/Handler/ProcessHandler.php#L130-L144
|
220,701
|
Seldaek/monolog
|
src/Monolog/Handler/ChromePHPHandler.php
|
ChromePHPHandler.write
|
protected function write(array $record): void
{
if (!$this->isWebRequest()) {
return;
}
self::$json['rows'][] = $record['formatted'];
$this->send();
}
|
php
|
protected function write(array $record): void
{
if (!$this->isWebRequest()) {
return;
}
self::$json['rows'][] = $record['formatted'];
$this->send();
}
|
[
"protected",
"function",
"write",
"(",
"array",
"$",
"record",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isWebRequest",
"(",
")",
")",
"{",
"return",
";",
"}",
"self",
"::",
"$",
"json",
"[",
"'rows'",
"]",
"[",
"]",
"=",
"$",
"record",
"[",
"'formatted'",
"]",
";",
"$",
"this",
"->",
"send",
"(",
")",
";",
"}"
] |
Creates & sends header for a record
@see sendHeader()
@see send()
|
[
"Creates",
"&",
"sends",
"header",
"for",
"a",
"record"
] |
ebb804e432e8fe0fe96828f30d89c45581d36d07
|
https://github.com/Seldaek/monolog/blob/ebb804e432e8fe0fe96828f30d89c45581d36d07/src/Monolog/Handler/ChromePHPHandler.php#L114-L123
|
220,702
|
Seldaek/monolog
|
src/Monolog/Handler/ChromePHPHandler.php
|
ChromePHPHandler.send
|
protected function send(): void
{
if (self::$overflowed || !self::$sendHeaders) {
return;
}
if (!self::$initialized) {
self::$initialized = true;
self::$sendHeaders = $this->headersAccepted();
if (!self::$sendHeaders) {
return;
}
self::$json['request_uri'] = $_SERVER['REQUEST_URI'] ?? '';
}
$json = @json_encode(self::$json);
$data = base64_encode(utf8_encode($json));
if (strlen($data) > 240 * 1024) {
self::$overflowed = true;
$record = [
'message' => 'Incomplete logs, chrome header size limit reached',
'context' => [],
'level' => Logger::WARNING,
'level_name' => Logger::getLevelName(Logger::WARNING),
'channel' => 'monolog',
'datetime' => new \DateTimeImmutable(),
'extra' => [],
];
self::$json['rows'][count(self::$json['rows']) - 1] = $this->getFormatter()->format($record);
$json = @json_encode(self::$json);
$data = base64_encode(utf8_encode($json));
}
if (trim($data) !== '') {
$this->sendHeader(static::HEADER_NAME, $data);
}
}
|
php
|
protected function send(): void
{
if (self::$overflowed || !self::$sendHeaders) {
return;
}
if (!self::$initialized) {
self::$initialized = true;
self::$sendHeaders = $this->headersAccepted();
if (!self::$sendHeaders) {
return;
}
self::$json['request_uri'] = $_SERVER['REQUEST_URI'] ?? '';
}
$json = @json_encode(self::$json);
$data = base64_encode(utf8_encode($json));
if (strlen($data) > 240 * 1024) {
self::$overflowed = true;
$record = [
'message' => 'Incomplete logs, chrome header size limit reached',
'context' => [],
'level' => Logger::WARNING,
'level_name' => Logger::getLevelName(Logger::WARNING),
'channel' => 'monolog',
'datetime' => new \DateTimeImmutable(),
'extra' => [],
];
self::$json['rows'][count(self::$json['rows']) - 1] = $this->getFormatter()->format($record);
$json = @json_encode(self::$json);
$data = base64_encode(utf8_encode($json));
}
if (trim($data) !== '') {
$this->sendHeader(static::HEADER_NAME, $data);
}
}
|
[
"protected",
"function",
"send",
"(",
")",
":",
"void",
"{",
"if",
"(",
"self",
"::",
"$",
"overflowed",
"||",
"!",
"self",
"::",
"$",
"sendHeaders",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"$",
"initialized",
")",
"{",
"self",
"::",
"$",
"initialized",
"=",
"true",
";",
"self",
"::",
"$",
"sendHeaders",
"=",
"$",
"this",
"->",
"headersAccepted",
"(",
")",
";",
"if",
"(",
"!",
"self",
"::",
"$",
"sendHeaders",
")",
"{",
"return",
";",
"}",
"self",
"::",
"$",
"json",
"[",
"'request_uri'",
"]",
"=",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
"??",
"''",
";",
"}",
"$",
"json",
"=",
"@",
"json_encode",
"(",
"self",
"::",
"$",
"json",
")",
";",
"$",
"data",
"=",
"base64_encode",
"(",
"utf8_encode",
"(",
"$",
"json",
")",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"data",
")",
">",
"240",
"*",
"1024",
")",
"{",
"self",
"::",
"$",
"overflowed",
"=",
"true",
";",
"$",
"record",
"=",
"[",
"'message'",
"=>",
"'Incomplete logs, chrome header size limit reached'",
",",
"'context'",
"=>",
"[",
"]",
",",
"'level'",
"=>",
"Logger",
"::",
"WARNING",
",",
"'level_name'",
"=>",
"Logger",
"::",
"getLevelName",
"(",
"Logger",
"::",
"WARNING",
")",
",",
"'channel'",
"=>",
"'monolog'",
",",
"'datetime'",
"=>",
"new",
"\\",
"DateTimeImmutable",
"(",
")",
",",
"'extra'",
"=>",
"[",
"]",
",",
"]",
";",
"self",
"::",
"$",
"json",
"[",
"'rows'",
"]",
"[",
"count",
"(",
"self",
"::",
"$",
"json",
"[",
"'rows'",
"]",
")",
"-",
"1",
"]",
"=",
"$",
"this",
"->",
"getFormatter",
"(",
")",
"->",
"format",
"(",
"$",
"record",
")",
";",
"$",
"json",
"=",
"@",
"json_encode",
"(",
"self",
"::",
"$",
"json",
")",
";",
"$",
"data",
"=",
"base64_encode",
"(",
"utf8_encode",
"(",
"$",
"json",
")",
")",
";",
"}",
"if",
"(",
"trim",
"(",
"$",
"data",
")",
"!==",
"''",
")",
"{",
"$",
"this",
"->",
"sendHeader",
"(",
"static",
"::",
"HEADER_NAME",
",",
"$",
"data",
")",
";",
"}",
"}"
] |
Sends the log header
@see sendHeader()
|
[
"Sends",
"the",
"log",
"header"
] |
ebb804e432e8fe0fe96828f30d89c45581d36d07
|
https://github.com/Seldaek/monolog/blob/ebb804e432e8fe0fe96828f30d89c45581d36d07/src/Monolog/Handler/ChromePHPHandler.php#L130-L169
|
220,703
|
Seldaek/monolog
|
src/Monolog/Handler/FirePHPHandler.php
|
FirePHPHandler.getInitHeaders
|
protected function getInitHeaders(): array
{
// Initial payload consists of required headers for Wildfire
return array_merge(
$this->createHeader(['Protocol', 1], static::PROTOCOL_URI),
$this->createHeader([1, 'Structure', 1], static::STRUCTURE_URI),
$this->createHeader([1, 'Plugin', 1], static::PLUGIN_URI)
);
}
|
php
|
protected function getInitHeaders(): array
{
// Initial payload consists of required headers for Wildfire
return array_merge(
$this->createHeader(['Protocol', 1], static::PROTOCOL_URI),
$this->createHeader([1, 'Structure', 1], static::STRUCTURE_URI),
$this->createHeader([1, 'Plugin', 1], static::PLUGIN_URI)
);
}
|
[
"protected",
"function",
"getInitHeaders",
"(",
")",
":",
"array",
"{",
"// Initial payload consists of required headers for Wildfire",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"createHeader",
"(",
"[",
"'Protocol'",
",",
"1",
"]",
",",
"static",
"::",
"PROTOCOL_URI",
")",
",",
"$",
"this",
"->",
"createHeader",
"(",
"[",
"1",
",",
"'Structure'",
",",
"1",
"]",
",",
"static",
"::",
"STRUCTURE_URI",
")",
",",
"$",
"this",
"->",
"createHeader",
"(",
"[",
"1",
",",
"'Plugin'",
",",
"1",
"]",
",",
"static",
"::",
"PLUGIN_URI",
")",
")",
";",
"}"
] |
Wildfire initialization headers to enable message parsing
@see createHeader()
@see sendHeader()
|
[
"Wildfire",
"initialization",
"headers",
"to",
"enable",
"message",
"parsing"
] |
ebb804e432e8fe0fe96828f30d89c45581d36d07
|
https://github.com/Seldaek/monolog/blob/ebb804e432e8fe0fe96828f30d89c45581d36d07/src/Monolog/Handler/FirePHPHandler.php#L102-L110
|
220,704
|
Seldaek/monolog
|
src/Monolog/Handler/SocketHandler.php
|
SocketHandler.setConnectionTimeout
|
public function setConnectionTimeout(float $seconds): self
{
$this->validateTimeout($seconds);
$this->connectionTimeout = $seconds;
return $this;
}
|
php
|
public function setConnectionTimeout(float $seconds): self
{
$this->validateTimeout($seconds);
$this->connectionTimeout = $seconds;
return $this;
}
|
[
"public",
"function",
"setConnectionTimeout",
"(",
"float",
"$",
"seconds",
")",
":",
"self",
"{",
"$",
"this",
"->",
"validateTimeout",
"(",
"$",
"seconds",
")",
";",
"$",
"this",
"->",
"connectionTimeout",
"=",
"$",
"seconds",
";",
"return",
"$",
"this",
";",
"}"
] |
Set connection timeout. Only has effect before we connect.
@see http://php.net/manual/en/function.fsockopen.php
|
[
"Set",
"connection",
"timeout",
".",
"Only",
"has",
"effect",
"before",
"we",
"connect",
"."
] |
ebb804e432e8fe0fe96828f30d89c45581d36d07
|
https://github.com/Seldaek/monolog/blob/ebb804e432e8fe0fe96828f30d89c45581d36d07/src/Monolog/Handler/SocketHandler.php#L103-L109
|
220,705
|
Seldaek/monolog
|
src/Monolog/Handler/SocketHandler.php
|
SocketHandler.setTimeout
|
public function setTimeout(float $seconds): self
{
$this->validateTimeout($seconds);
$this->timeout = $seconds;
return $this;
}
|
php
|
public function setTimeout(float $seconds): self
{
$this->validateTimeout($seconds);
$this->timeout = $seconds;
return $this;
}
|
[
"public",
"function",
"setTimeout",
"(",
"float",
"$",
"seconds",
")",
":",
"self",
"{",
"$",
"this",
"->",
"validateTimeout",
"(",
"$",
"seconds",
")",
";",
"$",
"this",
"->",
"timeout",
"=",
"$",
"seconds",
";",
"return",
"$",
"this",
";",
"}"
] |
Set write timeout. Only has effect before we connect.
@see http://php.net/manual/en/function.stream-set-timeout.php
|
[
"Set",
"write",
"timeout",
".",
"Only",
"has",
"effect",
"before",
"we",
"connect",
"."
] |
ebb804e432e8fe0fe96828f30d89c45581d36d07
|
https://github.com/Seldaek/monolog/blob/ebb804e432e8fe0fe96828f30d89c45581d36d07/src/Monolog/Handler/SocketHandler.php#L116-L122
|
220,706
|
Seldaek/monolog
|
src/Monolog/Handler/SocketHandler.php
|
SocketHandler.setWritingTimeout
|
public function setWritingTimeout(float $seconds): self
{
$this->validateTimeout($seconds);
$this->writingTimeout = $seconds;
return $this;
}
|
php
|
public function setWritingTimeout(float $seconds): self
{
$this->validateTimeout($seconds);
$this->writingTimeout = $seconds;
return $this;
}
|
[
"public",
"function",
"setWritingTimeout",
"(",
"float",
"$",
"seconds",
")",
":",
"self",
"{",
"$",
"this",
"->",
"validateTimeout",
"(",
"$",
"seconds",
")",
";",
"$",
"this",
"->",
"writingTimeout",
"=",
"$",
"seconds",
";",
"return",
"$",
"this",
";",
"}"
] |
Set writing timeout. Only has effect during connection in the writing cycle.
@param float $seconds 0 for no timeout
|
[
"Set",
"writing",
"timeout",
".",
"Only",
"has",
"effect",
"during",
"connection",
"in",
"the",
"writing",
"cycle",
"."
] |
ebb804e432e8fe0fe96828f30d89c45581d36d07
|
https://github.com/Seldaek/monolog/blob/ebb804e432e8fe0fe96828f30d89c45581d36d07/src/Monolog/Handler/SocketHandler.php#L129-L135
|
220,707
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/MetricPointController.php
|
MetricPointController.index
|
public function index(Metric $metric, MetricPoint $metricPoint)
{
$points = $metric->points()->paginate(Binput::get('per_page', 20));
return $this->paginator($points, Request::instance());
}
|
php
|
public function index(Metric $metric, MetricPoint $metricPoint)
{
$points = $metric->points()->paginate(Binput::get('per_page', 20));
return $this->paginator($points, Request::instance());
}
|
[
"public",
"function",
"index",
"(",
"Metric",
"$",
"metric",
",",
"MetricPoint",
"$",
"metricPoint",
")",
"{",
"$",
"points",
"=",
"$",
"metric",
"->",
"points",
"(",
")",
"->",
"paginate",
"(",
"Binput",
"::",
"get",
"(",
"'per_page'",
",",
"20",
")",
")",
";",
"return",
"$",
"this",
"->",
"paginator",
"(",
"$",
"points",
",",
"Request",
"::",
"instance",
"(",
")",
")",
";",
"}"
] |
Get a single metric point.
@param \CachetHQ\Cachet\Models\Metric $metric
@param \CachetHQ\Cachet\Models\MetricPoint $metricPoint
@return \Illuminate\Http\JsonResponse
|
[
"Get",
"a",
"single",
"metric",
"point",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/MetricPointController.php#L34-L39
|
220,708
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/MetricPointController.php
|
MetricPointController.store
|
public function store(Metric $metric)
{
try {
$metricPoint = execute(new CreateMetricPointCommand(
$metric,
Binput::get('value'),
Binput::get('timestamp')
));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->item($metricPoint);
}
|
php
|
public function store(Metric $metric)
{
try {
$metricPoint = execute(new CreateMetricPointCommand(
$metric,
Binput::get('value'),
Binput::get('timestamp')
));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->item($metricPoint);
}
|
[
"public",
"function",
"store",
"(",
"Metric",
"$",
"metric",
")",
"{",
"try",
"{",
"$",
"metricPoint",
"=",
"execute",
"(",
"new",
"CreateMetricPointCommand",
"(",
"$",
"metric",
",",
"Binput",
"::",
"get",
"(",
"'value'",
")",
",",
"Binput",
"::",
"get",
"(",
"'timestamp'",
")",
")",
")",
";",
"}",
"catch",
"(",
"QueryException",
"$",
"e",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"item",
"(",
"$",
"metricPoint",
")",
";",
"}"
] |
Create a new metric point.
@param \CachetHQ\Cachet\Models\Metric $metric
@return \Illuminate\Http\JsonResponse
|
[
"Create",
"a",
"new",
"metric",
"point",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/MetricPointController.php#L48-L61
|
220,709
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/MetricPointController.php
|
MetricPointController.update
|
public function update(Metric $metric, MetricPoint $metricPoint)
{
$metricPoint = execute(new UpdateMetricPointCommand(
$metricPoint,
$metric,
Binput::get('value'),
Binput::get('timestamp')
));
return $this->item($metricPoint);
}
|
php
|
public function update(Metric $metric, MetricPoint $metricPoint)
{
$metricPoint = execute(new UpdateMetricPointCommand(
$metricPoint,
$metric,
Binput::get('value'),
Binput::get('timestamp')
));
return $this->item($metricPoint);
}
|
[
"public",
"function",
"update",
"(",
"Metric",
"$",
"metric",
",",
"MetricPoint",
"$",
"metricPoint",
")",
"{",
"$",
"metricPoint",
"=",
"execute",
"(",
"new",
"UpdateMetricPointCommand",
"(",
"$",
"metricPoint",
",",
"$",
"metric",
",",
"Binput",
"::",
"get",
"(",
"'value'",
")",
",",
"Binput",
"::",
"get",
"(",
"'timestamp'",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"item",
"(",
"$",
"metricPoint",
")",
";",
"}"
] |
Updates a metric point.
@param \CachetHQ\Cachet\Models\Metric $metric
@param \CachetHQ\Cachet\Models\MetricPoint $metricPoint
@return \Illuminate\Http\JsonResponse
|
[
"Updates",
"a",
"metric",
"point",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/MetricPointController.php#L71-L81
|
220,710
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/MetricPointController.php
|
MetricPointController.destroy
|
public function destroy(Metric $metric, MetricPoint $metricPoint)
{
execute(new RemoveMetricPointCommand($metricPoint));
return $this->noContent();
}
|
php
|
public function destroy(Metric $metric, MetricPoint $metricPoint)
{
execute(new RemoveMetricPointCommand($metricPoint));
return $this->noContent();
}
|
[
"public",
"function",
"destroy",
"(",
"Metric",
"$",
"metric",
",",
"MetricPoint",
"$",
"metricPoint",
")",
"{",
"execute",
"(",
"new",
"RemoveMetricPointCommand",
"(",
"$",
"metricPoint",
")",
")",
";",
"return",
"$",
"this",
"->",
"noContent",
"(",
")",
";",
"}"
] |
Destroys a metric point.
@param \CachetHQ\Cachet\Models\Metric $metric
@param \CachetHQ\Cachet\Models\MetricPoint $metricPoint
@return \Illuminate\Http\JsonResponse
|
[
"Destroys",
"a",
"metric",
"point",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/MetricPointController.php#L91-L96
|
220,711
|
CachetHQ/Cachet
|
app/Bus/Middleware/UseDatabaseTransactions.php
|
UseDatabaseTransactions.handle
|
public function handle($command, Closure $next)
{
return DB::transaction(function () use ($command, $next) {
return $next($command);
});
}
|
php
|
public function handle($command, Closure $next)
{
return DB::transaction(function () use ($command, $next) {
return $next($command);
});
}
|
[
"public",
"function",
"handle",
"(",
"$",
"command",
",",
"Closure",
"$",
"next",
")",
"{",
"return",
"DB",
"::",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"command",
",",
"$",
"next",
")",
"{",
"return",
"$",
"next",
"(",
"$",
"command",
")",
";",
"}",
")",
";",
"}"
] |
Handle the current command in the pipeline.
@param mixed $command
@param \Closure $next
@return bool
|
[
"Handle",
"the",
"current",
"command",
"in",
"the",
"pipeline",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Middleware/UseDatabaseTransactions.php#L32-L37
|
220,712
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/User/GenerateApiTokenCommandHandler.php
|
GenerateApiTokenCommandHandler.handle
|
public function handle(GenerateApiTokenCommand $command)
{
$user = $command->user;
$user->update(['api_key' => User::generateApiKey()]);
event(new UserRegeneratedApiTokenEvent($user));
}
|
php
|
public function handle(GenerateApiTokenCommand $command)
{
$user = $command->user;
$user->update(['api_key' => User::generateApiKey()]);
event(new UserRegeneratedApiTokenEvent($user));
}
|
[
"public",
"function",
"handle",
"(",
"GenerateApiTokenCommand",
"$",
"command",
")",
"{",
"$",
"user",
"=",
"$",
"command",
"->",
"user",
";",
"$",
"user",
"->",
"update",
"(",
"[",
"'api_key'",
"=>",
"User",
"::",
"generateApiKey",
"(",
")",
"]",
")",
";",
"event",
"(",
"new",
"UserRegeneratedApiTokenEvent",
"(",
"$",
"user",
")",
")",
";",
"}"
] |
Handle the generate api key command.
@param \CachetHQ\Cachet\Bus\Commands\User\GenerateApiTokenCommand $command
@return void
|
[
"Handle",
"the",
"generate",
"api",
"key",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/User/GenerateApiTokenCommandHandler.php#L27-L34
|
220,713
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/ScheduleController.php
|
ScheduleController.index
|
public function index()
{
$schedule = Schedule::query();
if ($sortBy = Binput::get('sort')) {
$direction = Binput::has('order') && Binput::get('order') == 'desc';
$schedule->sort($sortBy, $direction);
}
$schedule = $schedule->paginate(Binput::get('per_page', 20));
return $this->paginator($schedule, Request::instance());
}
|
php
|
public function index()
{
$schedule = Schedule::query();
if ($sortBy = Binput::get('sort')) {
$direction = Binput::has('order') && Binput::get('order') == 'desc';
$schedule->sort($sortBy, $direction);
}
$schedule = $schedule->paginate(Binput::get('per_page', 20));
return $this->paginator($schedule, Request::instance());
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"$",
"schedule",
"=",
"Schedule",
"::",
"query",
"(",
")",
";",
"if",
"(",
"$",
"sortBy",
"=",
"Binput",
"::",
"get",
"(",
"'sort'",
")",
")",
"{",
"$",
"direction",
"=",
"Binput",
"::",
"has",
"(",
"'order'",
")",
"&&",
"Binput",
"::",
"get",
"(",
"'order'",
")",
"==",
"'desc'",
";",
"$",
"schedule",
"->",
"sort",
"(",
"$",
"sortBy",
",",
"$",
"direction",
")",
";",
"}",
"$",
"schedule",
"=",
"$",
"schedule",
"->",
"paginate",
"(",
"Binput",
"::",
"get",
"(",
"'per_page'",
",",
"20",
")",
")",
";",
"return",
"$",
"this",
"->",
"paginator",
"(",
"$",
"schedule",
",",
"Request",
"::",
"instance",
"(",
")",
")",
";",
"}"
] |
Return all schedules.
@return \Illuminate\Http\JsonResponse
|
[
"Return",
"all",
"schedules",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/ScheduleController.php#L35-L48
|
220,714
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/ScheduleController.php
|
ScheduleController.store
|
public function store()
{
try {
$schedule = execute(new CreateScheduleCommand(
Binput::get('name'),
Binput::get('message', null, false, false),
Binput::get('status'),
Binput::get('scheduled_at'),
Binput::get('completed_at'),
Binput::get('components', [])
));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->item($schedule);
}
|
php
|
public function store()
{
try {
$schedule = execute(new CreateScheduleCommand(
Binput::get('name'),
Binput::get('message', null, false, false),
Binput::get('status'),
Binput::get('scheduled_at'),
Binput::get('completed_at'),
Binput::get('components', [])
));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->item($schedule);
}
|
[
"public",
"function",
"store",
"(",
")",
"{",
"try",
"{",
"$",
"schedule",
"=",
"execute",
"(",
"new",
"CreateScheduleCommand",
"(",
"Binput",
"::",
"get",
"(",
"'name'",
")",
",",
"Binput",
"::",
"get",
"(",
"'message'",
",",
"null",
",",
"false",
",",
"false",
")",
",",
"Binput",
"::",
"get",
"(",
"'status'",
")",
",",
"Binput",
"::",
"get",
"(",
"'scheduled_at'",
")",
",",
"Binput",
"::",
"get",
"(",
"'completed_at'",
")",
",",
"Binput",
"::",
"get",
"(",
"'components'",
",",
"[",
"]",
")",
")",
")",
";",
"}",
"catch",
"(",
"QueryException",
"$",
"e",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"item",
"(",
"$",
"schedule",
")",
";",
"}"
] |
Create a new schedule.
@return \Illuminate\Http\JsonResponse
|
[
"Create",
"a",
"new",
"schedule",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/ScheduleController.php#L67-L83
|
220,715
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/ScheduleController.php
|
ScheduleController.update
|
public function update(Schedule $schedule)
{
try {
$schedule = execute(new UpdateScheduleCommand(
$schedule,
Binput::get('name'),
Binput::get('message'),
Binput::get('status'),
Binput::get('scheduled_at'),
Binput::get('completed_at'),
Binput::get('components', [])
));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->item($schedule);
}
|
php
|
public function update(Schedule $schedule)
{
try {
$schedule = execute(new UpdateScheduleCommand(
$schedule,
Binput::get('name'),
Binput::get('message'),
Binput::get('status'),
Binput::get('scheduled_at'),
Binput::get('completed_at'),
Binput::get('components', [])
));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->item($schedule);
}
|
[
"public",
"function",
"update",
"(",
"Schedule",
"$",
"schedule",
")",
"{",
"try",
"{",
"$",
"schedule",
"=",
"execute",
"(",
"new",
"UpdateScheduleCommand",
"(",
"$",
"schedule",
",",
"Binput",
"::",
"get",
"(",
"'name'",
")",
",",
"Binput",
"::",
"get",
"(",
"'message'",
")",
",",
"Binput",
"::",
"get",
"(",
"'status'",
")",
",",
"Binput",
"::",
"get",
"(",
"'scheduled_at'",
")",
",",
"Binput",
"::",
"get",
"(",
"'completed_at'",
")",
",",
"Binput",
"::",
"get",
"(",
"'components'",
",",
"[",
"]",
")",
")",
")",
";",
"}",
"catch",
"(",
"QueryException",
"$",
"e",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"item",
"(",
"$",
"schedule",
")",
";",
"}"
] |
Update a schedule.
@param \CachetHQ\Cachet\Models\Schedule $schedule
@return \Illuminate\Http\JsonResponse
|
[
"Update",
"a",
"schedule",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/ScheduleController.php#L92-L109
|
220,716
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/ScheduleController.php
|
ScheduleController.destroy
|
public function destroy(Schedule $schedule)
{
try {
execute(new DeleteScheduleCommand($schedule));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->noContent();
}
|
php
|
public function destroy(Schedule $schedule)
{
try {
execute(new DeleteScheduleCommand($schedule));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->noContent();
}
|
[
"public",
"function",
"destroy",
"(",
"Schedule",
"$",
"schedule",
")",
"{",
"try",
"{",
"execute",
"(",
"new",
"DeleteScheduleCommand",
"(",
"$",
"schedule",
")",
")",
";",
"}",
"catch",
"(",
"QueryException",
"$",
"e",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"noContent",
"(",
")",
";",
"}"
] |
Delete a schedule.
@param \CachetHQ\Cachet\Models\Schedule $schedule
@return \Illuminate\Http\JsonResponse
|
[
"Delete",
"a",
"schedule",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/ScheduleController.php#L118-L127
|
220,717
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Metric/UpdateMetricPointCommandHandler.php
|
UpdateMetricPointCommandHandler.handle
|
public function handle(UpdateMetricPointCommand $command)
{
$point = $command->point;
$metric = $command->metric;
$createdAt = $command->created_at;
$data = [
'metric_id' => $metric->id,
'value' => (float) $command->value,
];
if ($createdAt) {
$data['created_at'] = $this->dates->create('U', $createdAt)->format('Y-m-d H:i:s');
}
$point->update($data);
event(new MetricPointWasUpdatedEvent($this->auth->user(), $point));
return $point;
}
|
php
|
public function handle(UpdateMetricPointCommand $command)
{
$point = $command->point;
$metric = $command->metric;
$createdAt = $command->created_at;
$data = [
'metric_id' => $metric->id,
'value' => (float) $command->value,
];
if ($createdAt) {
$data['created_at'] = $this->dates->create('U', $createdAt)->format('Y-m-d H:i:s');
}
$point->update($data);
event(new MetricPointWasUpdatedEvent($this->auth->user(), $point));
return $point;
}
|
[
"public",
"function",
"handle",
"(",
"UpdateMetricPointCommand",
"$",
"command",
")",
"{",
"$",
"point",
"=",
"$",
"command",
"->",
"point",
";",
"$",
"metric",
"=",
"$",
"command",
"->",
"metric",
";",
"$",
"createdAt",
"=",
"$",
"command",
"->",
"created_at",
";",
"$",
"data",
"=",
"[",
"'metric_id'",
"=>",
"$",
"metric",
"->",
"id",
",",
"'value'",
"=>",
"(",
"float",
")",
"$",
"command",
"->",
"value",
",",
"]",
";",
"if",
"(",
"$",
"createdAt",
")",
"{",
"$",
"data",
"[",
"'created_at'",
"]",
"=",
"$",
"this",
"->",
"dates",
"->",
"create",
"(",
"'U'",
",",
"$",
"createdAt",
")",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
";",
"}",
"$",
"point",
"->",
"update",
"(",
"$",
"data",
")",
";",
"event",
"(",
"new",
"MetricPointWasUpdatedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"point",
")",
")",
";",
"return",
"$",
"point",
";",
"}"
] |
Handle the update metric point command.
@param \CachetHQ\Cachet\Bus\Commands\Metric\UpdateMetricPointCommand $command
@return \CachetHQ\Cachet\Models\MetricPoint
|
[
"Handle",
"the",
"update",
"metric",
"point",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Metric/UpdateMetricPointCommandHandler.php#L56-L76
|
220,718
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/User/InviteUserCommandHandler.php
|
InviteUserCommandHandler.handle
|
public function handle(InviteUserCommand $command)
{
foreach ($command->emails as $email) {
$invite = Invite::create([
'email' => $email,
]);
$invite->notify(new InviteUserNotification());
event(new UserWasInvitedEvent($invite));
}
}
|
php
|
public function handle(InviteUserCommand $command)
{
foreach ($command->emails as $email) {
$invite = Invite::create([
'email' => $email,
]);
$invite->notify(new InviteUserNotification());
event(new UserWasInvitedEvent($invite));
}
}
|
[
"public",
"function",
"handle",
"(",
"InviteUserCommand",
"$",
"command",
")",
"{",
"foreach",
"(",
"$",
"command",
"->",
"emails",
"as",
"$",
"email",
")",
"{",
"$",
"invite",
"=",
"Invite",
"::",
"create",
"(",
"[",
"'email'",
"=>",
"$",
"email",
",",
"]",
")",
";",
"$",
"invite",
"->",
"notify",
"(",
"new",
"InviteUserNotification",
"(",
")",
")",
";",
"event",
"(",
"new",
"UserWasInvitedEvent",
"(",
"$",
"invite",
")",
")",
";",
"}",
"}"
] |
Handle the invite team member command.
@param \CachetHQ\Cachet\Bus\Commands\User\InviteUserCommand $command
@return void
|
[
"Handle",
"the",
"invite",
"team",
"member",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/User/InviteUserCommandHandler.php#L33-L44
|
220,719
|
CachetHQ/Cachet
|
app/Subscribers/CommandSubscriber.php
|
CommandSubscriber.fireInstallingCommand
|
public function fireInstallingCommand(Command $command)
{
$this->handleMainCommand($command);
event(new SystemWasInstalledEvent());
$command->info('System was installed!');
}
|
php
|
public function fireInstallingCommand(Command $command)
{
$this->handleMainCommand($command);
event(new SystemWasInstalledEvent());
$command->info('System was installed!');
}
|
[
"public",
"function",
"fireInstallingCommand",
"(",
"Command",
"$",
"command",
")",
"{",
"$",
"this",
"->",
"handleMainCommand",
"(",
"$",
"command",
")",
";",
"event",
"(",
"new",
"SystemWasInstalledEvent",
"(",
")",
")",
";",
"$",
"command",
"->",
"info",
"(",
"'System was installed!'",
")",
";",
"}"
] |
Fire the installing command.
@param \Illuminate\Console\Command $command
@return void
|
[
"Fire",
"the",
"installing",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Subscribers/CommandSubscriber.php#L78-L85
|
220,720
|
CachetHQ/Cachet
|
app/Subscribers/CommandSubscriber.php
|
CommandSubscriber.fireUpdatingCommand
|
public function fireUpdatingCommand(Command $command)
{
$this->handleMainCommand($command);
event(new SystemWasUpdatedEvent());
$command->info('System was updated!');
}
|
php
|
public function fireUpdatingCommand(Command $command)
{
$this->handleMainCommand($command);
event(new SystemWasUpdatedEvent());
$command->info('System was updated!');
}
|
[
"public",
"function",
"fireUpdatingCommand",
"(",
"Command",
"$",
"command",
")",
"{",
"$",
"this",
"->",
"handleMainCommand",
"(",
"$",
"command",
")",
";",
"event",
"(",
"new",
"SystemWasUpdatedEvent",
"(",
")",
")",
";",
"$",
"command",
"->",
"info",
"(",
"'System was updated!'",
")",
";",
"}"
] |
Fire the updating command.
@param \Illuminate\Console\Command $command
@return void
|
[
"Fire",
"the",
"updating",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Subscribers/CommandSubscriber.php#L94-L101
|
220,721
|
CachetHQ/Cachet
|
app/Subscribers/CommandSubscriber.php
|
CommandSubscriber.fireResettingCommand
|
public function fireResettingCommand(Command $command)
{
$this->handleMainCommand($command);
event(new SystemWasResetEvent());
$command->info('System was reset!');
}
|
php
|
public function fireResettingCommand(Command $command)
{
$this->handleMainCommand($command);
event(new SystemWasResetEvent());
$command->info('System was reset!');
}
|
[
"public",
"function",
"fireResettingCommand",
"(",
"Command",
"$",
"command",
")",
"{",
"$",
"this",
"->",
"handleMainCommand",
"(",
"$",
"command",
")",
";",
"event",
"(",
"new",
"SystemWasResetEvent",
"(",
")",
")",
";",
"$",
"command",
"->",
"info",
"(",
"'System was reset!'",
")",
";",
"}"
] |
Fire the resetting command.
@param \Illuminate\Console\Command $command
@return void
|
[
"Fire",
"the",
"resetting",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Subscribers/CommandSubscriber.php#L110-L117
|
220,722
|
CachetHQ/Cachet
|
app/Subscribers/CommandSubscriber.php
|
CommandSubscriber.handleMainCommand
|
protected function handleMainCommand(Command $command)
{
$command->line('Clearing settings cache...');
$this->cache->clear();
$command->line('Settings cache cleared!');
}
|
php
|
protected function handleMainCommand(Command $command)
{
$command->line('Clearing settings cache...');
$this->cache->clear();
$command->line('Settings cache cleared!');
}
|
[
"protected",
"function",
"handleMainCommand",
"(",
"Command",
"$",
"command",
")",
"{",
"$",
"command",
"->",
"line",
"(",
"'Clearing settings cache...'",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"clear",
"(",
")",
";",
"$",
"command",
"->",
"line",
"(",
"'Settings cache cleared!'",
")",
";",
"}"
] |
Handle the main bulk of the command, clear the settings.
@param \Illuminate\Console\Command $command
@return void
|
[
"Handle",
"the",
"main",
"bulk",
"of",
"the",
"command",
"clear",
"the",
"settings",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Subscribers/CommandSubscriber.php#L126-L133
|
220,723
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Component/UpdateComponentCommandHandler.php
|
UpdateComponentCommandHandler.handle
|
public function handle(UpdateComponentCommand $command)
{
$component = $command->component;
$originalStatus = $component->status;
if ($command->status && (int) $originalStatus !== (int) $command->status) {
event(new ComponentStatusWasChangedEvent($this->auth->user(), $component, $originalStatus, $command->status, $command->silent));
}
$component->update($this->filter($command));
event(new ComponentWasUpdatedEvent($this->auth->user(), $component));
return $component;
}
|
php
|
public function handle(UpdateComponentCommand $command)
{
$component = $command->component;
$originalStatus = $component->status;
if ($command->status && (int) $originalStatus !== (int) $command->status) {
event(new ComponentStatusWasChangedEvent($this->auth->user(), $component, $originalStatus, $command->status, $command->silent));
}
$component->update($this->filter($command));
event(new ComponentWasUpdatedEvent($this->auth->user(), $component));
return $component;
}
|
[
"public",
"function",
"handle",
"(",
"UpdateComponentCommand",
"$",
"command",
")",
"{",
"$",
"component",
"=",
"$",
"command",
"->",
"component",
";",
"$",
"originalStatus",
"=",
"$",
"component",
"->",
"status",
";",
"if",
"(",
"$",
"command",
"->",
"status",
"&&",
"(",
"int",
")",
"$",
"originalStatus",
"!==",
"(",
"int",
")",
"$",
"command",
"->",
"status",
")",
"{",
"event",
"(",
"new",
"ComponentStatusWasChangedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"component",
",",
"$",
"originalStatus",
",",
"$",
"command",
"->",
"status",
",",
"$",
"command",
"->",
"silent",
")",
")",
";",
"}",
"$",
"component",
"->",
"update",
"(",
"$",
"this",
"->",
"filter",
"(",
"$",
"command",
")",
")",
";",
"event",
"(",
"new",
"ComponentWasUpdatedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"component",
")",
")",
";",
"return",
"$",
"component",
";",
"}"
] |
Handle the update component command.
@param \CachetHQ\Cachet\Bus\Commands\Component\UpdateComponentCommand $command
@return \CachetHQ\Cachet\Models\Component
|
[
"Handle",
"the",
"update",
"component",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Component/UpdateComponentCommandHandler.php#L48-L62
|
220,724
|
CachetHQ/Cachet
|
app/Models/Incident.php
|
Incident.getIsResolvedAttribute
|
public function getIsResolvedAttribute()
{
if ($updates = $this->updates->first()) {
return (int) $updates->status === self::FIXED;
}
return (int) $this->status === self::FIXED;
}
|
php
|
public function getIsResolvedAttribute()
{
if ($updates = $this->updates->first()) {
return (int) $updates->status === self::FIXED;
}
return (int) $this->status === self::FIXED;
}
|
[
"public",
"function",
"getIsResolvedAttribute",
"(",
")",
"{",
"if",
"(",
"$",
"updates",
"=",
"$",
"this",
"->",
"updates",
"->",
"first",
"(",
")",
")",
"{",
"return",
"(",
"int",
")",
"$",
"updates",
"->",
"status",
"===",
"self",
"::",
"FIXED",
";",
"}",
"return",
"(",
"int",
")",
"$",
"this",
"->",
"status",
"===",
"self",
"::",
"FIXED",
";",
"}"
] |
Is the incident resolved?
@return bool
|
[
"Is",
"the",
"incident",
"resolved?"
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Models/Incident.php#L239-L246
|
220,725
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php
|
UpdateIncidentCommandHandler.handle
|
public function handle(UpdateIncidentCommand $command)
{
if ($template = IncidentTemplate::where('slug', '=', $command->template)->first()) {
$command->message = $this->parseTemplate($template, $command);
}
$incident = $command->incident;
$incident->fill($this->filter($command));
// The incident occurred at a different time.
if ($occurredAt = $command->occurred_at) {
if ($date = $this->dates->create('Y-m-d H:i', $occurredAt)) {
$incident->fill(['occurred_at' => $date]);
} else {
throw new InvalidIncidentTimestampException("Unable to pass timestamp {$occurredAt}");
}
}
// Rather than making lots of updates, just fill and save.
$incident->save();
// Store any meta?
if ($meta = $command->meta) {
$this->storeMeta($command->meta, 'incidents', $incident->id);
}
// Update the component.
if ($component = Component::find($command->component_id)) {
execute(new UpdateComponentCommand(
Component::find($command->component_id),
null,
null,
$command->component_status,
null,
null,
null,
null,
null,
false
));
}
event(new IncidentWasUpdatedEvent($this->auth->user(), $incident));
return $incident;
}
|
php
|
public function handle(UpdateIncidentCommand $command)
{
if ($template = IncidentTemplate::where('slug', '=', $command->template)->first()) {
$command->message = $this->parseTemplate($template, $command);
}
$incident = $command->incident;
$incident->fill($this->filter($command));
// The incident occurred at a different time.
if ($occurredAt = $command->occurred_at) {
if ($date = $this->dates->create('Y-m-d H:i', $occurredAt)) {
$incident->fill(['occurred_at' => $date]);
} else {
throw new InvalidIncidentTimestampException("Unable to pass timestamp {$occurredAt}");
}
}
// Rather than making lots of updates, just fill and save.
$incident->save();
// Store any meta?
if ($meta = $command->meta) {
$this->storeMeta($command->meta, 'incidents', $incident->id);
}
// Update the component.
if ($component = Component::find($command->component_id)) {
execute(new UpdateComponentCommand(
Component::find($command->component_id),
null,
null,
$command->component_status,
null,
null,
null,
null,
null,
false
));
}
event(new IncidentWasUpdatedEvent($this->auth->user(), $incident));
return $incident;
}
|
[
"public",
"function",
"handle",
"(",
"UpdateIncidentCommand",
"$",
"command",
")",
"{",
"if",
"(",
"$",
"template",
"=",
"IncidentTemplate",
"::",
"where",
"(",
"'slug'",
",",
"'='",
",",
"$",
"command",
"->",
"template",
")",
"->",
"first",
"(",
")",
")",
"{",
"$",
"command",
"->",
"message",
"=",
"$",
"this",
"->",
"parseTemplate",
"(",
"$",
"template",
",",
"$",
"command",
")",
";",
"}",
"$",
"incident",
"=",
"$",
"command",
"->",
"incident",
";",
"$",
"incident",
"->",
"fill",
"(",
"$",
"this",
"->",
"filter",
"(",
"$",
"command",
")",
")",
";",
"// The incident occurred at a different time.",
"if",
"(",
"$",
"occurredAt",
"=",
"$",
"command",
"->",
"occurred_at",
")",
"{",
"if",
"(",
"$",
"date",
"=",
"$",
"this",
"->",
"dates",
"->",
"create",
"(",
"'Y-m-d H:i'",
",",
"$",
"occurredAt",
")",
")",
"{",
"$",
"incident",
"->",
"fill",
"(",
"[",
"'occurred_at'",
"=>",
"$",
"date",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidIncidentTimestampException",
"(",
"\"Unable to pass timestamp {$occurredAt}\"",
")",
";",
"}",
"}",
"// Rather than making lots of updates, just fill and save.",
"$",
"incident",
"->",
"save",
"(",
")",
";",
"// Store any meta?",
"if",
"(",
"$",
"meta",
"=",
"$",
"command",
"->",
"meta",
")",
"{",
"$",
"this",
"->",
"storeMeta",
"(",
"$",
"command",
"->",
"meta",
",",
"'incidents'",
",",
"$",
"incident",
"->",
"id",
")",
";",
"}",
"// Update the component.",
"if",
"(",
"$",
"component",
"=",
"Component",
"::",
"find",
"(",
"$",
"command",
"->",
"component_id",
")",
")",
"{",
"execute",
"(",
"new",
"UpdateComponentCommand",
"(",
"Component",
"::",
"find",
"(",
"$",
"command",
"->",
"component_id",
")",
",",
"null",
",",
"null",
",",
"$",
"command",
"->",
"component_status",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"false",
")",
")",
";",
"}",
"event",
"(",
"new",
"IncidentWasUpdatedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"incident",
")",
")",
";",
"return",
"$",
"incident",
";",
"}"
] |
Handle the update incident command.
@param \CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand $command
@return \CachetHQ\Cachet\Models\Incident
|
[
"Handle",
"the",
"update",
"incident",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php#L71-L116
|
220,726
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php
|
UpdateIncidentCommandHandler.parseTemplate
|
protected function parseTemplate(IncidentTemplate $template, UpdateIncidentCommand $command)
{
$env = new Twig_Environment(new Twig_Loader_Array([]));
$template = $env->createTemplate($template->template);
$vars = array_merge($command->template_vars, [
'incident' => [
'name' => $command->name,
'status' => $command->status,
'message' => $command->message,
'visible' => $command->visible,
'notify' => $command->notify,
'stickied' => $command->stickied,
'occurred_at' => $command->occurred_at,
'component' => Component::find($command->component_id) ?: null,
'component_status' => $command->component_status,
],
]);
return $template->render($vars);
}
|
php
|
protected function parseTemplate(IncidentTemplate $template, UpdateIncidentCommand $command)
{
$env = new Twig_Environment(new Twig_Loader_Array([]));
$template = $env->createTemplate($template->template);
$vars = array_merge($command->template_vars, [
'incident' => [
'name' => $command->name,
'status' => $command->status,
'message' => $command->message,
'visible' => $command->visible,
'notify' => $command->notify,
'stickied' => $command->stickied,
'occurred_at' => $command->occurred_at,
'component' => Component::find($command->component_id) ?: null,
'component_status' => $command->component_status,
],
]);
return $template->render($vars);
}
|
[
"protected",
"function",
"parseTemplate",
"(",
"IncidentTemplate",
"$",
"template",
",",
"UpdateIncidentCommand",
"$",
"command",
")",
"{",
"$",
"env",
"=",
"new",
"Twig_Environment",
"(",
"new",
"Twig_Loader_Array",
"(",
"[",
"]",
")",
")",
";",
"$",
"template",
"=",
"$",
"env",
"->",
"createTemplate",
"(",
"$",
"template",
"->",
"template",
")",
";",
"$",
"vars",
"=",
"array_merge",
"(",
"$",
"command",
"->",
"template_vars",
",",
"[",
"'incident'",
"=>",
"[",
"'name'",
"=>",
"$",
"command",
"->",
"name",
",",
"'status'",
"=>",
"$",
"command",
"->",
"status",
",",
"'message'",
"=>",
"$",
"command",
"->",
"message",
",",
"'visible'",
"=>",
"$",
"command",
"->",
"visible",
",",
"'notify'",
"=>",
"$",
"command",
"->",
"notify",
",",
"'stickied'",
"=>",
"$",
"command",
"->",
"stickied",
",",
"'occurred_at'",
"=>",
"$",
"command",
"->",
"occurred_at",
",",
"'component'",
"=>",
"Component",
"::",
"find",
"(",
"$",
"command",
"->",
"component_id",
")",
"?",
":",
"null",
",",
"'component_status'",
"=>",
"$",
"command",
"->",
"component_status",
",",
"]",
",",
"]",
")",
";",
"return",
"$",
"template",
"->",
"render",
"(",
"$",
"vars",
")",
";",
"}"
] |
Compiles an incident template into an incident message.
@param \CachetHQ\Cachet\Models\IncidentTemplate $template
@param \CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand $command
@return string
|
[
"Compiles",
"an",
"incident",
"template",
"into",
"an",
"incident",
"message",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php#L151-L171
|
220,727
|
CachetHQ/Cachet
|
app/Models/Schedule.php
|
Schedule.scopeInProgress
|
public function scopeInProgress(Builder $query)
{
return $query->where('scheduled_at', '<=', Carbon::now())->where('status', '<>', self::COMPLETE)->where(function ($query) {
$query->whereNull('completed_at')->orWhere('completed_at', '>', Carbon::now());
});
}
|
php
|
public function scopeInProgress(Builder $query)
{
return $query->where('scheduled_at', '<=', Carbon::now())->where('status', '<>', self::COMPLETE)->where(function ($query) {
$query->whereNull('completed_at')->orWhere('completed_at', '>', Carbon::now());
});
}
|
[
"public",
"function",
"scopeInProgress",
"(",
"Builder",
"$",
"query",
")",
"{",
"return",
"$",
"query",
"->",
"where",
"(",
"'scheduled_at'",
",",
"'<='",
",",
"Carbon",
"::",
"now",
"(",
")",
")",
"->",
"where",
"(",
"'status'",
",",
"'<>'",
",",
"self",
"::",
"COMPLETE",
")",
"->",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"{",
"$",
"query",
"->",
"whereNull",
"(",
"'completed_at'",
")",
"->",
"orWhere",
"(",
"'completed_at'",
",",
"'>'",
",",
"Carbon",
"::",
"now",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] |
Scope schedules that are in progress.
@param \Illuminate\Database\Eloquent\Builder $query
@return \Illuminate\Database\Eloquent\Builder
|
[
"Scope",
"schedules",
"that",
"are",
"in",
"progress",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Models/Schedule.php#L158-L163
|
220,728
|
CachetHQ/Cachet
|
app/Models/Schedule.php
|
Schedule.scopeFutureSchedules
|
public function scopeFutureSchedules($query)
{
return $query->whereIn('status', [self::UPCOMING, self::IN_PROGRESS])->where('scheduled_at', '>=', Carbon::now());
}
|
php
|
public function scopeFutureSchedules($query)
{
return $query->whereIn('status', [self::UPCOMING, self::IN_PROGRESS])->where('scheduled_at', '>=', Carbon::now());
}
|
[
"public",
"function",
"scopeFutureSchedules",
"(",
"$",
"query",
")",
"{",
"return",
"$",
"query",
"->",
"whereIn",
"(",
"'status'",
",",
"[",
"self",
"::",
"UPCOMING",
",",
"self",
"::",
"IN_PROGRESS",
"]",
")",
"->",
"where",
"(",
"'scheduled_at'",
",",
"'>='",
",",
"Carbon",
"::",
"now",
"(",
")",
")",
";",
"}"
] |
Scopes schedules to those in the future.
@param \Illuminate\Database\Eloquent\Builder $query
@return \Illuminate\Database\Eloquent\Builder
|
[
"Scopes",
"schedules",
"to",
"those",
"in",
"the",
"future",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Models/Schedule.php#L172-L175
|
220,729
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Metric/RemoveMetricCommandHandler.php
|
RemoveMetricCommandHandler.handle
|
public function handle(RemoveMetricCommand $command)
{
$metric = $command->metric;
event(new MetricWasRemovedEvent($this->auth->user(), $metric));
$metric->delete();
}
|
php
|
public function handle(RemoveMetricCommand $command)
{
$metric = $command->metric;
event(new MetricWasRemovedEvent($this->auth->user(), $metric));
$metric->delete();
}
|
[
"public",
"function",
"handle",
"(",
"RemoveMetricCommand",
"$",
"command",
")",
"{",
"$",
"metric",
"=",
"$",
"command",
"->",
"metric",
";",
"event",
"(",
"new",
"MetricWasRemovedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"metric",
")",
")",
";",
"$",
"metric",
"->",
"delete",
"(",
")",
";",
"}"
] |
Handle the remove metric command.
@param \CachetHQ\Cachet\Bus\Commands\Metric\RemoveMetricCommand $command
@return void
|
[
"Handle",
"the",
"remove",
"metric",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Metric/RemoveMetricCommandHandler.php#L47-L54
|
220,730
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/User/SignupUserCommandHandler.php
|
SignupUserCommandHandler.handle
|
public function handle(SignupUserCommand $command)
{
$user = User::create([
'username' => $command->username,
'password' => $command->password,
'email' => $command->email,
'level' => User::LEVEL_USER,
]);
event(new UserWasCreatedEvent($user));
return $user;
}
|
php
|
public function handle(SignupUserCommand $command)
{
$user = User::create([
'username' => $command->username,
'password' => $command->password,
'email' => $command->email,
'level' => User::LEVEL_USER,
]);
event(new UserWasCreatedEvent($user));
return $user;
}
|
[
"public",
"function",
"handle",
"(",
"SignupUserCommand",
"$",
"command",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"create",
"(",
"[",
"'username'",
"=>",
"$",
"command",
"->",
"username",
",",
"'password'",
"=>",
"$",
"command",
"->",
"password",
",",
"'email'",
"=>",
"$",
"command",
"->",
"email",
",",
"'level'",
"=>",
"User",
"::",
"LEVEL_USER",
",",
"]",
")",
";",
"event",
"(",
"new",
"UserWasCreatedEvent",
"(",
"$",
"user",
")",
")",
";",
"return",
"$",
"user",
";",
"}"
] |
Handle the signup user command.
@param \CachetHQ\Cachet\Bus\Commands\User\SignupUserCommand $command
@return \CachetHQ\Cachet\Models\User
|
[
"Handle",
"the",
"signup",
"user",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/User/SignupUserCommandHandler.php#L27-L39
|
220,731
|
CachetHQ/Cachet
|
app/Presenters/UserPresenter.php
|
UserPresenter.avatar
|
public function avatar()
{
if (Config::get('setting.enable_external_dependencies')) {
return sprintf('https://www.gravatar.com/avatar/%s?size=%d', md5(strtolower($this->email)), 200);
}
return Avatar::create($this->username)->toBase64();
}
|
php
|
public function avatar()
{
if (Config::get('setting.enable_external_dependencies')) {
return sprintf('https://www.gravatar.com/avatar/%s?size=%d', md5(strtolower($this->email)), 200);
}
return Avatar::create($this->username)->toBase64();
}
|
[
"public",
"function",
"avatar",
"(",
")",
"{",
"if",
"(",
"Config",
"::",
"get",
"(",
"'setting.enable_external_dependencies'",
")",
")",
"{",
"return",
"sprintf",
"(",
"'https://www.gravatar.com/avatar/%s?size=%d'",
",",
"md5",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"email",
")",
")",
",",
"200",
")",
";",
"}",
"return",
"Avatar",
"::",
"create",
"(",
"$",
"this",
"->",
"username",
")",
"->",
"toBase64",
"(",
")",
";",
"}"
] |
Returns the users avatar.
@return string
|
[
"Returns",
"the",
"users",
"avatar",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Presenters/UserPresenter.php#L31-L38
|
220,732
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/User/WelcomeUserCommandHandler.php
|
WelcomeUserCommandHandler.handle
|
public function handle(WelcomeUserCommand $command)
{
$command->user->update(['welcomed' => true]);
event(new UserWasWelcomedEvent($command->user));
}
|
php
|
public function handle(WelcomeUserCommand $command)
{
$command->user->update(['welcomed' => true]);
event(new UserWasWelcomedEvent($command->user));
}
|
[
"public",
"function",
"handle",
"(",
"WelcomeUserCommand",
"$",
"command",
")",
"{",
"$",
"command",
"->",
"user",
"->",
"update",
"(",
"[",
"'welcomed'",
"=>",
"true",
"]",
")",
";",
"event",
"(",
"new",
"UserWasWelcomedEvent",
"(",
"$",
"command",
"->",
"user",
")",
")",
";",
"}"
] |
Handle the welcome user command.
@param \CachetHQ\Cachet\Bus\Commands\User\WelcomeUserCommand $command
@return void
|
[
"Handle",
"the",
"welcome",
"user",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/User/WelcomeUserCommandHandler.php#L31-L36
|
220,733
|
CachetHQ/Cachet
|
app/Http/Controllers/Dashboard/IncidentUpdateController.php
|
IncidentUpdateController.showCreateIncidentUpdateAction
|
public function showCreateIncidentUpdateAction(Incident $incident)
{
return View::make('dashboard.incidents.updates.add')
->withIncident($incident)
->withNotificationsEnabled($this->system->canNotifySubscribers());
}
|
php
|
public function showCreateIncidentUpdateAction(Incident $incident)
{
return View::make('dashboard.incidents.updates.add')
->withIncident($incident)
->withNotificationsEnabled($this->system->canNotifySubscribers());
}
|
[
"public",
"function",
"showCreateIncidentUpdateAction",
"(",
"Incident",
"$",
"incident",
")",
"{",
"return",
"View",
"::",
"make",
"(",
"'dashboard.incidents.updates.add'",
")",
"->",
"withIncident",
"(",
"$",
"incident",
")",
"->",
"withNotificationsEnabled",
"(",
"$",
"this",
"->",
"system",
"->",
"canNotifySubscribers",
"(",
")",
")",
";",
"}"
] |
Shows the incident update form.
@param \CachetHQ\Cachet\Models\Incident $incident
@return \Illuminate\View\View
|
[
"Shows",
"the",
"incident",
"update",
"form",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/IncidentUpdateController.php#L87-L92
|
220,734
|
CachetHQ/Cachet
|
app/Http/Controllers/Dashboard/IncidentUpdateController.php
|
IncidentUpdateController.createIncidentUpdateAction
|
public function createIncidentUpdateAction(Incident $incident)
{
try {
$incidentUpdate = execute(new CreateIncidentUpdateCommand(
$incident,
Binput::get('status'),
Binput::get('message'),
Binput::get('component_id'),
Binput::get('component_status'),
$this->auth->user()
));
} catch (ValidationException $e) {
return cachet_redirect('dashboard.incidents.updates.create', ['id' => $incident->id])
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.updates.add.failure')))
->withErrors($e->getMessageBag());
}
if ($incident->component) {
$incident->component->update(['status' => Binput::get('component_status')]);
}
return cachet_redirect('dashboard.incidents')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.updates.success')));
}
|
php
|
public function createIncidentUpdateAction(Incident $incident)
{
try {
$incidentUpdate = execute(new CreateIncidentUpdateCommand(
$incident,
Binput::get('status'),
Binput::get('message'),
Binput::get('component_id'),
Binput::get('component_status'),
$this->auth->user()
));
} catch (ValidationException $e) {
return cachet_redirect('dashboard.incidents.updates.create', ['id' => $incident->id])
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.updates.add.failure')))
->withErrors($e->getMessageBag());
}
if ($incident->component) {
$incident->component->update(['status' => Binput::get('component_status')]);
}
return cachet_redirect('dashboard.incidents')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.updates.success')));
}
|
[
"public",
"function",
"createIncidentUpdateAction",
"(",
"Incident",
"$",
"incident",
")",
"{",
"try",
"{",
"$",
"incidentUpdate",
"=",
"execute",
"(",
"new",
"CreateIncidentUpdateCommand",
"(",
"$",
"incident",
",",
"Binput",
"::",
"get",
"(",
"'status'",
")",
",",
"Binput",
"::",
"get",
"(",
"'message'",
")",
",",
"Binput",
"::",
"get",
"(",
"'component_id'",
")",
",",
"Binput",
"::",
"get",
"(",
"'component_status'",
")",
",",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"ValidationException",
"$",
"e",
")",
"{",
"return",
"cachet_redirect",
"(",
"'dashboard.incidents.updates.create'",
",",
"[",
"'id'",
"=>",
"$",
"incident",
"->",
"id",
"]",
")",
"->",
"withInput",
"(",
"Binput",
"::",
"all",
"(",
")",
")",
"->",
"withTitle",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.whoops'",
")",
",",
"trans",
"(",
"'dashboard.incidents.updates.add.failure'",
")",
")",
")",
"->",
"withErrors",
"(",
"$",
"e",
"->",
"getMessageBag",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"incident",
"->",
"component",
")",
"{",
"$",
"incident",
"->",
"component",
"->",
"update",
"(",
"[",
"'status'",
"=>",
"Binput",
"::",
"get",
"(",
"'component_status'",
")",
"]",
")",
";",
"}",
"return",
"cachet_redirect",
"(",
"'dashboard.incidents'",
")",
"->",
"withSuccess",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.awesome'",
")",
",",
"trans",
"(",
"'dashboard.incidents.updates.success'",
")",
")",
")",
";",
"}"
] |
Creates a new incident update.
@param \CachetHQ\Cachet\Models\Incident $incident
@return \Illuminate\Http\RedirectResponse
|
[
"Creates",
"a",
"new",
"incident",
"update",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/IncidentUpdateController.php#L101-L125
|
220,735
|
CachetHQ/Cachet
|
app/Http/Controllers/Dashboard/IncidentUpdateController.php
|
IncidentUpdateController.editIncidentUpdateAction
|
public function editIncidentUpdateAction(Incident $incident, IncidentUpdate $incidentUpdate)
{
try {
$incidentUpdate = execute(new UpdateIncidentUpdateCommand(
$incidentUpdate,
Binput::get('status'),
Binput::get('message'),
$this->auth->user()
));
} catch (ValidationException $e) {
return cachet_redirect('dashboard.incidents.updates.edit', ['incident' => $incident->id, 'incident_update' => $incidentUpdate->id])
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.updates.edit.failure')))
->withErrors($e->getMessageBag());
}
return cachet_redirect('dashboard.incidents.updates', ['incident' => $incident->id])
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.updates.edit.success')));
}
|
php
|
public function editIncidentUpdateAction(Incident $incident, IncidentUpdate $incidentUpdate)
{
try {
$incidentUpdate = execute(new UpdateIncidentUpdateCommand(
$incidentUpdate,
Binput::get('status'),
Binput::get('message'),
$this->auth->user()
));
} catch (ValidationException $e) {
return cachet_redirect('dashboard.incidents.updates.edit', ['incident' => $incident->id, 'incident_update' => $incidentUpdate->id])
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.updates.edit.failure')))
->withErrors($e->getMessageBag());
}
return cachet_redirect('dashboard.incidents.updates', ['incident' => $incident->id])
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.updates.edit.success')));
}
|
[
"public",
"function",
"editIncidentUpdateAction",
"(",
"Incident",
"$",
"incident",
",",
"IncidentUpdate",
"$",
"incidentUpdate",
")",
"{",
"try",
"{",
"$",
"incidentUpdate",
"=",
"execute",
"(",
"new",
"UpdateIncidentUpdateCommand",
"(",
"$",
"incidentUpdate",
",",
"Binput",
"::",
"get",
"(",
"'status'",
")",
",",
"Binput",
"::",
"get",
"(",
"'message'",
")",
",",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"ValidationException",
"$",
"e",
")",
"{",
"return",
"cachet_redirect",
"(",
"'dashboard.incidents.updates.edit'",
",",
"[",
"'incident'",
"=>",
"$",
"incident",
"->",
"id",
",",
"'incident_update'",
"=>",
"$",
"incidentUpdate",
"->",
"id",
"]",
")",
"->",
"withInput",
"(",
"Binput",
"::",
"all",
"(",
")",
")",
"->",
"withTitle",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.whoops'",
")",
",",
"trans",
"(",
"'dashboard.incidents.updates.edit.failure'",
")",
")",
")",
"->",
"withErrors",
"(",
"$",
"e",
"->",
"getMessageBag",
"(",
")",
")",
";",
"}",
"return",
"cachet_redirect",
"(",
"'dashboard.incidents.updates'",
",",
"[",
"'incident'",
"=>",
"$",
"incident",
"->",
"id",
"]",
")",
"->",
"withSuccess",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.awesome'",
")",
",",
"trans",
"(",
"'dashboard.incidents.updates.edit.success'",
")",
")",
")",
";",
"}"
] |
Edit an incident update.
@param \CachetHQ\Cachet\Models\Incident $incident
@param \CachetHQ\Cachet\Models\IncidentUpdate $incidentUpdate
@return \Illuminate\Http\RedirectResponse
|
[
"Edit",
"an",
"incident",
"update",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/IncidentUpdateController.php#L151-L169
|
220,736
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Schedule/CreateScheduleCommandHandler.php
|
CreateScheduleCommandHandler.handle
|
public function handle(CreateScheduleCommand $command)
{
try {
$schedule = Schedule::create($this->filter($command));
event(new ScheduleWasCreatedEvent($this->auth->user(), $schedule));
} catch (InvalidArgumentException $e) {
throw new ValidationException(new MessageBag([$e->getMessage()]));
}
return $schedule;
}
|
php
|
public function handle(CreateScheduleCommand $command)
{
try {
$schedule = Schedule::create($this->filter($command));
event(new ScheduleWasCreatedEvent($this->auth->user(), $schedule));
} catch (InvalidArgumentException $e) {
throw new ValidationException(new MessageBag([$e->getMessage()]));
}
return $schedule;
}
|
[
"public",
"function",
"handle",
"(",
"CreateScheduleCommand",
"$",
"command",
")",
"{",
"try",
"{",
"$",
"schedule",
"=",
"Schedule",
"::",
"create",
"(",
"$",
"this",
"->",
"filter",
"(",
"$",
"command",
")",
")",
";",
"event",
"(",
"new",
"ScheduleWasCreatedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"schedule",
")",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"throw",
"new",
"ValidationException",
"(",
"new",
"MessageBag",
"(",
"[",
"$",
"e",
"->",
"getMessage",
"(",
")",
"]",
")",
")",
";",
"}",
"return",
"$",
"schedule",
";",
"}"
] |
Handle the create schedule command.
@param \CachetHQ\Cachet\Bus\Commands\Schedule\CreateScheduleCommand $command
@return \CachetHQ\Cachet\Models\Schedule
|
[
"Handle",
"the",
"create",
"schedule",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Schedule/CreateScheduleCommandHandler.php#L65-L76
|
220,737
|
CachetHQ/Cachet
|
app/Models/Traits/HasTags.php
|
HasTags.convertToTags
|
protected static function convertToTags($values)
{
return collect($values)->map(function ($value) {
if ($value instanceof Tag) {
return $value;
}
return Tag::where('slug', '=', $value)->first();
});
}
|
php
|
protected static function convertToTags($values)
{
return collect($values)->map(function ($value) {
if ($value instanceof Tag) {
return $value;
}
return Tag::where('slug', '=', $value)->first();
});
}
|
[
"protected",
"static",
"function",
"convertToTags",
"(",
"$",
"values",
")",
"{",
"return",
"collect",
"(",
"$",
"values",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Tag",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"Tag",
"::",
"where",
"(",
"'slug'",
",",
"'='",
",",
"$",
"value",
")",
"->",
"first",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Convert a list of tags into a collection of \CachetHQ\Cachet\Models\Tag.
@param array|\ArrayAccess $values
@return \Illuminate\Support\Collection
|
[
"Convert",
"a",
"list",
"of",
"tags",
"into",
"a",
"collection",
"of",
"\\",
"CachetHQ",
"\\",
"Cachet",
"\\",
"Models",
"\\",
"Tag",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Models/Traits/HasTags.php#L77-L86
|
220,738
|
CachetHQ/Cachet
|
app/Integrations/Core/System.php
|
System.getStatus
|
public function getStatus()
{
$includePrivate = $this->auth->check();
$totalComponents = Component::enabled()->authenticated($includePrivate)->count();
$majorOutages = Component::enabled()->authenticated($includePrivate)->status(4)->count();
$majorOutageRate = (int) $this->config->get('setting.major_outage_rate', '50');
$isMajorOutage = $totalComponents ? ($majorOutages / $totalComponents) * 100 >= $majorOutageRate : false;
// Default data
$status = [
'system_status' => 'info',
'system_message' => trans_choice('cachet.service.bad', $totalComponents),
'favicon' => 'favicon-high-alert',
];
if ($isMajorOutage) {
$status = [
'system_status' => 'danger',
'system_message' => trans_choice('cachet.service.major', $totalComponents),
'favicon' => 'favicon-high-alert',
];
} elseif (Component::enabled()->authenticated($includePrivate)->notStatus(1)->count() === 0) {
// If all our components are ok, do we have any non-fixed incidents?
$incidents = Incident::orderBy('occurred_at', 'desc')->get()->filter(function ($incident) {
return $incident->status !== Incident::FIXED;
});
$incidentCount = $incidents->count();
$unresolvedCount = $incidents->filter(function ($incident) {
return !$incident->is_resolved;
})->count();
if ($incidentCount === 0 || ($incidentCount >= 1 && $unresolvedCount === 0)) {
$status = [
'system_status' => 'success',
'system_message' => trans_choice('cachet.service.good', $totalComponents),
'favicon' => 'favicon',
];
}
} elseif (Component::enabled()->authenticated($includePrivate)->whereIn('status', [2, 3])->count() > 0) {
$status['favicon'] = 'favicon-medium-alert';
}
return $status;
}
|
php
|
public function getStatus()
{
$includePrivate = $this->auth->check();
$totalComponents = Component::enabled()->authenticated($includePrivate)->count();
$majorOutages = Component::enabled()->authenticated($includePrivate)->status(4)->count();
$majorOutageRate = (int) $this->config->get('setting.major_outage_rate', '50');
$isMajorOutage = $totalComponents ? ($majorOutages / $totalComponents) * 100 >= $majorOutageRate : false;
// Default data
$status = [
'system_status' => 'info',
'system_message' => trans_choice('cachet.service.bad', $totalComponents),
'favicon' => 'favicon-high-alert',
];
if ($isMajorOutage) {
$status = [
'system_status' => 'danger',
'system_message' => trans_choice('cachet.service.major', $totalComponents),
'favicon' => 'favicon-high-alert',
];
} elseif (Component::enabled()->authenticated($includePrivate)->notStatus(1)->count() === 0) {
// If all our components are ok, do we have any non-fixed incidents?
$incidents = Incident::orderBy('occurred_at', 'desc')->get()->filter(function ($incident) {
return $incident->status !== Incident::FIXED;
});
$incidentCount = $incidents->count();
$unresolvedCount = $incidents->filter(function ($incident) {
return !$incident->is_resolved;
})->count();
if ($incidentCount === 0 || ($incidentCount >= 1 && $unresolvedCount === 0)) {
$status = [
'system_status' => 'success',
'system_message' => trans_choice('cachet.service.good', $totalComponents),
'favicon' => 'favicon',
];
}
} elseif (Component::enabled()->authenticated($includePrivate)->whereIn('status', [2, 3])->count() > 0) {
$status['favicon'] = 'favicon-medium-alert';
}
return $status;
}
|
[
"public",
"function",
"getStatus",
"(",
")",
"{",
"$",
"includePrivate",
"=",
"$",
"this",
"->",
"auth",
"->",
"check",
"(",
")",
";",
"$",
"totalComponents",
"=",
"Component",
"::",
"enabled",
"(",
")",
"->",
"authenticated",
"(",
"$",
"includePrivate",
")",
"->",
"count",
"(",
")",
";",
"$",
"majorOutages",
"=",
"Component",
"::",
"enabled",
"(",
")",
"->",
"authenticated",
"(",
"$",
"includePrivate",
")",
"->",
"status",
"(",
"4",
")",
"->",
"count",
"(",
")",
";",
"$",
"majorOutageRate",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.major_outage_rate'",
",",
"'50'",
")",
";",
"$",
"isMajorOutage",
"=",
"$",
"totalComponents",
"?",
"(",
"$",
"majorOutages",
"/",
"$",
"totalComponents",
")",
"*",
"100",
">=",
"$",
"majorOutageRate",
":",
"false",
";",
"// Default data",
"$",
"status",
"=",
"[",
"'system_status'",
"=>",
"'info'",
",",
"'system_message'",
"=>",
"trans_choice",
"(",
"'cachet.service.bad'",
",",
"$",
"totalComponents",
")",
",",
"'favicon'",
"=>",
"'favicon-high-alert'",
",",
"]",
";",
"if",
"(",
"$",
"isMajorOutage",
")",
"{",
"$",
"status",
"=",
"[",
"'system_status'",
"=>",
"'danger'",
",",
"'system_message'",
"=>",
"trans_choice",
"(",
"'cachet.service.major'",
",",
"$",
"totalComponents",
")",
",",
"'favicon'",
"=>",
"'favicon-high-alert'",
",",
"]",
";",
"}",
"elseif",
"(",
"Component",
"::",
"enabled",
"(",
")",
"->",
"authenticated",
"(",
"$",
"includePrivate",
")",
"->",
"notStatus",
"(",
"1",
")",
"->",
"count",
"(",
")",
"===",
"0",
")",
"{",
"// If all our components are ok, do we have any non-fixed incidents?",
"$",
"incidents",
"=",
"Incident",
"::",
"orderBy",
"(",
"'occurred_at'",
",",
"'desc'",
")",
"->",
"get",
"(",
")",
"->",
"filter",
"(",
"function",
"(",
"$",
"incident",
")",
"{",
"return",
"$",
"incident",
"->",
"status",
"!==",
"Incident",
"::",
"FIXED",
";",
"}",
")",
";",
"$",
"incidentCount",
"=",
"$",
"incidents",
"->",
"count",
"(",
")",
";",
"$",
"unresolvedCount",
"=",
"$",
"incidents",
"->",
"filter",
"(",
"function",
"(",
"$",
"incident",
")",
"{",
"return",
"!",
"$",
"incident",
"->",
"is_resolved",
";",
"}",
")",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"incidentCount",
"===",
"0",
"||",
"(",
"$",
"incidentCount",
">=",
"1",
"&&",
"$",
"unresolvedCount",
"===",
"0",
")",
")",
"{",
"$",
"status",
"=",
"[",
"'system_status'",
"=>",
"'success'",
",",
"'system_message'",
"=>",
"trans_choice",
"(",
"'cachet.service.good'",
",",
"$",
"totalComponents",
")",
",",
"'favicon'",
"=>",
"'favicon'",
",",
"]",
";",
"}",
"}",
"elseif",
"(",
"Component",
"::",
"enabled",
"(",
")",
"->",
"authenticated",
"(",
"$",
"includePrivate",
")",
"->",
"whereIn",
"(",
"'status'",
",",
"[",
"2",
",",
"3",
"]",
")",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"$",
"status",
"[",
"'favicon'",
"]",
"=",
"'favicon-medium-alert'",
";",
"}",
"return",
"$",
"status",
";",
"}"
] |
Get the entire system status.
@return array
|
[
"Get",
"the",
"entire",
"system",
"status",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Integrations/Core/System.php#L61-L105
|
220,739
|
CachetHQ/Cachet
|
app/Integrations/Core/System.php
|
System.canNotifySubscribers
|
public function canNotifySubscribers()
{
$maintenancePeriods = Schedule::inProgress()->count();
if ($maintenancePeriods === 0) {
return true;
}
return !$this->config->get('setting.suppress_notifications_in_maintenance');
}
|
php
|
public function canNotifySubscribers()
{
$maintenancePeriods = Schedule::inProgress()->count();
if ($maintenancePeriods === 0) {
return true;
}
return !$this->config->get('setting.suppress_notifications_in_maintenance');
}
|
[
"public",
"function",
"canNotifySubscribers",
"(",
")",
"{",
"$",
"maintenancePeriods",
"=",
"Schedule",
"::",
"inProgress",
"(",
")",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"maintenancePeriods",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
"!",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.suppress_notifications_in_maintenance'",
")",
";",
"}"
] |
Determine if Cachet is allowed to send notifications to users, subscribers or third party tools.
@return bool
|
[
"Determine",
"if",
"Cachet",
"is",
"allowed",
"to",
"send",
"notifications",
"to",
"users",
"subscribers",
"or",
"third",
"party",
"tools",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Integrations/Core/System.php#L112-L120
|
220,740
|
CachetHQ/Cachet
|
app/Composers/TimezoneLocaleComposer.php
|
TimezoneLocaleComposer.compose
|
public function compose(View $view)
{
$enabledLangs = $this->config->get('langs');
$langs = array_map(function ($lang) use ($enabledLangs) {
$locale = basename($lang);
return [$locale => Arr::get($enabledLangs, $locale, [
'name' => $locale,
'subset' => null,
])];
}, glob(base_path('resources/lang').'/*'));
$langs = call_user_func_array('array_merge', $langs);
$regions = [
'UTC' => DateTimeZone::UTC,
'Africa' => DateTimeZone::AFRICA,
'America' => DateTimeZone::AMERICA,
'Antarctica' => DateTimeZone::ANTARCTICA,
'Arctic' => DateTimeZone::ARCTIC,
'Asia' => DateTimeZone::ASIA,
'Atlantic' => DateTimeZone::ATLANTIC,
'Australia' => DateTimeZone::AUSTRALIA,
'Europe' => DateTimeZone::EUROPE,
'Indian' => DateTimeZone::INDIAN,
'Pacific' => DateTimeZone::PACIFIC,
];
$timezones = [];
foreach ($regions as $name => $mask) {
$zones = DateTimeZone::listIdentifiers($mask);
foreach ($zones as $timezone) {
// Lets sample the time there right now
$time = new DateTime(null, new DateTimeZone($timezone));
if ($timezone !== 'UTC') {
// Remove region name and add a sample time
$timezones[$name][$timezone] = substr($timezone, strlen($name) + 1).' - '.$time->format('H:i');
} else {
$timezones[$name][$timezone] = 'UTC - '.$time->format('H:i');
}
$timezones[$name] = str_replace('_', ' ', $timezones[$name]);
}
}
$view->withTimezones($timezones);
$view->withLangs($langs);
}
|
php
|
public function compose(View $view)
{
$enabledLangs = $this->config->get('langs');
$langs = array_map(function ($lang) use ($enabledLangs) {
$locale = basename($lang);
return [$locale => Arr::get($enabledLangs, $locale, [
'name' => $locale,
'subset' => null,
])];
}, glob(base_path('resources/lang').'/*'));
$langs = call_user_func_array('array_merge', $langs);
$regions = [
'UTC' => DateTimeZone::UTC,
'Africa' => DateTimeZone::AFRICA,
'America' => DateTimeZone::AMERICA,
'Antarctica' => DateTimeZone::ANTARCTICA,
'Arctic' => DateTimeZone::ARCTIC,
'Asia' => DateTimeZone::ASIA,
'Atlantic' => DateTimeZone::ATLANTIC,
'Australia' => DateTimeZone::AUSTRALIA,
'Europe' => DateTimeZone::EUROPE,
'Indian' => DateTimeZone::INDIAN,
'Pacific' => DateTimeZone::PACIFIC,
];
$timezones = [];
foreach ($regions as $name => $mask) {
$zones = DateTimeZone::listIdentifiers($mask);
foreach ($zones as $timezone) {
// Lets sample the time there right now
$time = new DateTime(null, new DateTimeZone($timezone));
if ($timezone !== 'UTC') {
// Remove region name and add a sample time
$timezones[$name][$timezone] = substr($timezone, strlen($name) + 1).' - '.$time->format('H:i');
} else {
$timezones[$name][$timezone] = 'UTC - '.$time->format('H:i');
}
$timezones[$name] = str_replace('_', ' ', $timezones[$name]);
}
}
$view->withTimezones($timezones);
$view->withLangs($langs);
}
|
[
"public",
"function",
"compose",
"(",
"View",
"$",
"view",
")",
"{",
"$",
"enabledLangs",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'langs'",
")",
";",
"$",
"langs",
"=",
"array_map",
"(",
"function",
"(",
"$",
"lang",
")",
"use",
"(",
"$",
"enabledLangs",
")",
"{",
"$",
"locale",
"=",
"basename",
"(",
"$",
"lang",
")",
";",
"return",
"[",
"$",
"locale",
"=>",
"Arr",
"::",
"get",
"(",
"$",
"enabledLangs",
",",
"$",
"locale",
",",
"[",
"'name'",
"=>",
"$",
"locale",
",",
"'subset'",
"=>",
"null",
",",
"]",
")",
"]",
";",
"}",
",",
"glob",
"(",
"base_path",
"(",
"'resources/lang'",
")",
".",
"'/*'",
")",
")",
";",
"$",
"langs",
"=",
"call_user_func_array",
"(",
"'array_merge'",
",",
"$",
"langs",
")",
";",
"$",
"regions",
"=",
"[",
"'UTC'",
"=>",
"DateTimeZone",
"::",
"UTC",
",",
"'Africa'",
"=>",
"DateTimeZone",
"::",
"AFRICA",
",",
"'America'",
"=>",
"DateTimeZone",
"::",
"AMERICA",
",",
"'Antarctica'",
"=>",
"DateTimeZone",
"::",
"ANTARCTICA",
",",
"'Arctic'",
"=>",
"DateTimeZone",
"::",
"ARCTIC",
",",
"'Asia'",
"=>",
"DateTimeZone",
"::",
"ASIA",
",",
"'Atlantic'",
"=>",
"DateTimeZone",
"::",
"ATLANTIC",
",",
"'Australia'",
"=>",
"DateTimeZone",
"::",
"AUSTRALIA",
",",
"'Europe'",
"=>",
"DateTimeZone",
"::",
"EUROPE",
",",
"'Indian'",
"=>",
"DateTimeZone",
"::",
"INDIAN",
",",
"'Pacific'",
"=>",
"DateTimeZone",
"::",
"PACIFIC",
",",
"]",
";",
"$",
"timezones",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"regions",
"as",
"$",
"name",
"=>",
"$",
"mask",
")",
"{",
"$",
"zones",
"=",
"DateTimeZone",
"::",
"listIdentifiers",
"(",
"$",
"mask",
")",
";",
"foreach",
"(",
"$",
"zones",
"as",
"$",
"timezone",
")",
"{",
"// Lets sample the time there right now",
"$",
"time",
"=",
"new",
"DateTime",
"(",
"null",
",",
"new",
"DateTimeZone",
"(",
"$",
"timezone",
")",
")",
";",
"if",
"(",
"$",
"timezone",
"!==",
"'UTC'",
")",
"{",
"// Remove region name and add a sample time",
"$",
"timezones",
"[",
"$",
"name",
"]",
"[",
"$",
"timezone",
"]",
"=",
"substr",
"(",
"$",
"timezone",
",",
"strlen",
"(",
"$",
"name",
")",
"+",
"1",
")",
".",
"' - '",
".",
"$",
"time",
"->",
"format",
"(",
"'H:i'",
")",
";",
"}",
"else",
"{",
"$",
"timezones",
"[",
"$",
"name",
"]",
"[",
"$",
"timezone",
"]",
"=",
"'UTC - '",
".",
"$",
"time",
"->",
"format",
"(",
"'H:i'",
")",
";",
"}",
"$",
"timezones",
"[",
"$",
"name",
"]",
"=",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"timezones",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}",
"$",
"view",
"->",
"withTimezones",
"(",
"$",
"timezones",
")",
";",
"$",
"view",
"->",
"withLangs",
"(",
"$",
"langs",
")",
";",
"}"
] |
Timezones and Locales composer.
@param \Illuminate\Contracts\View\View $view
@return void
|
[
"Timezones",
"and",
"Locales",
"composer",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Composers/TimezoneLocaleComposer.php#L55-L106
|
220,741
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/ComponentGroup/UpdateComponentGroupCommandHandler.php
|
UpdateComponentGroupCommandHandler.handle
|
public function handle(UpdateComponentGroupCommand $command)
{
$group = $command->group;
$group->update($this->filter($command));
event(new ComponentGroupWasUpdatedEvent($this->auth->user(), $group));
return $group;
}
|
php
|
public function handle(UpdateComponentGroupCommand $command)
{
$group = $command->group;
$group->update($this->filter($command));
event(new ComponentGroupWasUpdatedEvent($this->auth->user(), $group));
return $group;
}
|
[
"public",
"function",
"handle",
"(",
"UpdateComponentGroupCommand",
"$",
"command",
")",
"{",
"$",
"group",
"=",
"$",
"command",
"->",
"group",
";",
"$",
"group",
"->",
"update",
"(",
"$",
"this",
"->",
"filter",
"(",
"$",
"command",
")",
")",
";",
"event",
"(",
"new",
"ComponentGroupWasUpdatedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"group",
")",
")",
";",
"return",
"$",
"group",
";",
"}"
] |
Handle the update component group command.
@param \CachetHQ\Cachet\Bus\Commands\ComponentGroup\UpdateComponentGroupCommand $command
@return \CachetHQ\Cachet\Models\ComponentGroup
|
[
"Handle",
"the",
"update",
"component",
"group",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/ComponentGroup/UpdateComponentGroupCommandHandler.php#L46-L54
|
220,742
|
CachetHQ/Cachet
|
app/Foundation/Providers/RepositoryServiceProvider.php
|
RepositoryServiceProvider.registerMetricRepository
|
protected function registerMetricRepository()
{
$this->app->singleton(MetricRepository::class, function (Container $app) {
$config = $app->make(ConfigRepository::class);
switch ($config->get('database.default')) {
case 'mysql': $repository = new MySqlRepository($config); break;
case 'pgsql': $repository = new PgSqlRepository($config); break;
case 'sqlite': $repository = new SqliteRepository($config); break;
}
$dates = $app->make(DateFactory::class);
return new MetricRepository($repository, $dates);
});
}
|
php
|
protected function registerMetricRepository()
{
$this->app->singleton(MetricRepository::class, function (Container $app) {
$config = $app->make(ConfigRepository::class);
switch ($config->get('database.default')) {
case 'mysql': $repository = new MySqlRepository($config); break;
case 'pgsql': $repository = new PgSqlRepository($config); break;
case 'sqlite': $repository = new SqliteRepository($config); break;
}
$dates = $app->make(DateFactory::class);
return new MetricRepository($repository, $dates);
});
}
|
[
"protected",
"function",
"registerMetricRepository",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"MetricRepository",
"::",
"class",
",",
"function",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"$",
"app",
"->",
"make",
"(",
"ConfigRepository",
"::",
"class",
")",
";",
"switch",
"(",
"$",
"config",
"->",
"get",
"(",
"'database.default'",
")",
")",
"{",
"case",
"'mysql'",
":",
"$",
"repository",
"=",
"new",
"MySqlRepository",
"(",
"$",
"config",
")",
";",
"break",
";",
"case",
"'pgsql'",
":",
"$",
"repository",
"=",
"new",
"PgSqlRepository",
"(",
"$",
"config",
")",
";",
"break",
";",
"case",
"'sqlite'",
":",
"$",
"repository",
"=",
"new",
"SqliteRepository",
"(",
"$",
"config",
")",
";",
"break",
";",
"}",
"$",
"dates",
"=",
"$",
"app",
"->",
"make",
"(",
"DateFactory",
"::",
"class",
")",
";",
"return",
"new",
"MetricRepository",
"(",
"$",
"repository",
",",
"$",
"dates",
")",
";",
"}",
")",
";",
"}"
] |
Register the metric repository.
@return void
|
[
"Register",
"the",
"metric",
"repository",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Foundation/Providers/RepositoryServiceProvider.php#L45-L60
|
220,743
|
CachetHQ/Cachet
|
app/Http/Routes/Dashboard/IncidentRoutes.php
|
IncidentRoutes.map
|
public function map(Registrar $router)
{
$router->group([
'middleware' => ['auth'],
'namespace' => 'Dashboard',
'prefix' => 'dashboard/incidents',
], function (Registrar $router) {
$router->get('/', [
'as' => 'get:dashboard.incidents',
'uses' => 'IncidentController@showIncidents',
]);
$router->get('create', [
'as' => 'get:dashboard.incidents.create',
'uses' => 'IncidentController@showAddIncident',
]);
$router->post('create', [
'as' => 'post:dashboard.incidents.create',
'uses' => 'IncidentController@createIncidentAction',
]);
$router->get('{incident}', [
'as' => 'get:dashboard.incidents.edit',
'uses' => 'IncidentController@showEditIncidentAction',
]);
$router->post('{incident}', [
'as' => 'post:dashboard.incidents.edit',
'uses' => 'IncidentController@editIncidentAction',
]);
$router->delete('{incident}', [
'as' => 'delete:dashboard.incidents.delete',
'uses' => 'IncidentController@deleteIncidentAction',
]);
$router->get('{incident}/updates', [
'as' => 'get:dashboard.incidents.updates',
'uses' => 'IncidentUpdateController@showIncidentUpdates',
]);
$router->get('{incident}/updates/create', [
'as' => 'get:dashboard.incidents.updates.create',
'uses' => 'IncidentUpdateController@showCreateIncidentUpdateAction',
]);
$router->post('{incident}/updates/create', [
'as' => 'post:dashboard.incidents.updates.create',
'uses' => 'IncidentUpdateController@createIncidentUpdateAction',
]);
$router->get('{incident}/updates/{incident_update}', [
'as' => 'get:dashboard.incidents.updates.edit',
'uses' => 'IncidentUpdateController@showEditIncidentUpdateAction',
]);
$router->post('{incident}/updates/{incident_update}', [
'as' => 'post:dashboard.incidents.updates.edit',
'uses' => 'IncidentUpdateController@editIncidentUpdateAction',
]);
});
}
|
php
|
public function map(Registrar $router)
{
$router->group([
'middleware' => ['auth'],
'namespace' => 'Dashboard',
'prefix' => 'dashboard/incidents',
], function (Registrar $router) {
$router->get('/', [
'as' => 'get:dashboard.incidents',
'uses' => 'IncidentController@showIncidents',
]);
$router->get('create', [
'as' => 'get:dashboard.incidents.create',
'uses' => 'IncidentController@showAddIncident',
]);
$router->post('create', [
'as' => 'post:dashboard.incidents.create',
'uses' => 'IncidentController@createIncidentAction',
]);
$router->get('{incident}', [
'as' => 'get:dashboard.incidents.edit',
'uses' => 'IncidentController@showEditIncidentAction',
]);
$router->post('{incident}', [
'as' => 'post:dashboard.incidents.edit',
'uses' => 'IncidentController@editIncidentAction',
]);
$router->delete('{incident}', [
'as' => 'delete:dashboard.incidents.delete',
'uses' => 'IncidentController@deleteIncidentAction',
]);
$router->get('{incident}/updates', [
'as' => 'get:dashboard.incidents.updates',
'uses' => 'IncidentUpdateController@showIncidentUpdates',
]);
$router->get('{incident}/updates/create', [
'as' => 'get:dashboard.incidents.updates.create',
'uses' => 'IncidentUpdateController@showCreateIncidentUpdateAction',
]);
$router->post('{incident}/updates/create', [
'as' => 'post:dashboard.incidents.updates.create',
'uses' => 'IncidentUpdateController@createIncidentUpdateAction',
]);
$router->get('{incident}/updates/{incident_update}', [
'as' => 'get:dashboard.incidents.updates.edit',
'uses' => 'IncidentUpdateController@showEditIncidentUpdateAction',
]);
$router->post('{incident}/updates/{incident_update}', [
'as' => 'post:dashboard.incidents.updates.edit',
'uses' => 'IncidentUpdateController@editIncidentUpdateAction',
]);
});
}
|
[
"public",
"function",
"map",
"(",
"Registrar",
"$",
"router",
")",
"{",
"$",
"router",
"->",
"group",
"(",
"[",
"'middleware'",
"=>",
"[",
"'auth'",
"]",
",",
"'namespace'",
"=>",
"'Dashboard'",
",",
"'prefix'",
"=>",
"'dashboard/incidents'",
",",
"]",
",",
"function",
"(",
"Registrar",
"$",
"router",
")",
"{",
"$",
"router",
"->",
"get",
"(",
"'/'",
",",
"[",
"'as'",
"=>",
"'get:dashboard.incidents'",
",",
"'uses'",
"=>",
"'IncidentController@showIncidents'",
",",
"]",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'create'",
",",
"[",
"'as'",
"=>",
"'get:dashboard.incidents.create'",
",",
"'uses'",
"=>",
"'IncidentController@showAddIncident'",
",",
"]",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'create'",
",",
"[",
"'as'",
"=>",
"'post:dashboard.incidents.create'",
",",
"'uses'",
"=>",
"'IncidentController@createIncidentAction'",
",",
"]",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'{incident}'",
",",
"[",
"'as'",
"=>",
"'get:dashboard.incidents.edit'",
",",
"'uses'",
"=>",
"'IncidentController@showEditIncidentAction'",
",",
"]",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'{incident}'",
",",
"[",
"'as'",
"=>",
"'post:dashboard.incidents.edit'",
",",
"'uses'",
"=>",
"'IncidentController@editIncidentAction'",
",",
"]",
")",
";",
"$",
"router",
"->",
"delete",
"(",
"'{incident}'",
",",
"[",
"'as'",
"=>",
"'delete:dashboard.incidents.delete'",
",",
"'uses'",
"=>",
"'IncidentController@deleteIncidentAction'",
",",
"]",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'{incident}/updates'",
",",
"[",
"'as'",
"=>",
"'get:dashboard.incidents.updates'",
",",
"'uses'",
"=>",
"'IncidentUpdateController@showIncidentUpdates'",
",",
"]",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'{incident}/updates/create'",
",",
"[",
"'as'",
"=>",
"'get:dashboard.incidents.updates.create'",
",",
"'uses'",
"=>",
"'IncidentUpdateController@showCreateIncidentUpdateAction'",
",",
"]",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'{incident}/updates/create'",
",",
"[",
"'as'",
"=>",
"'post:dashboard.incidents.updates.create'",
",",
"'uses'",
"=>",
"'IncidentUpdateController@createIncidentUpdateAction'",
",",
"]",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'{incident}/updates/{incident_update}'",
",",
"[",
"'as'",
"=>",
"'get:dashboard.incidents.updates.edit'",
",",
"'uses'",
"=>",
"'IncidentUpdateController@showEditIncidentUpdateAction'",
",",
"]",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'{incident}/updates/{incident_update}'",
",",
"[",
"'as'",
"=>",
"'post:dashboard.incidents.updates.edit'",
",",
"'uses'",
"=>",
"'IncidentUpdateController@editIncidentUpdateAction'",
",",
"]",
")",
";",
"}",
")",
";",
"}"
] |
Define the dashboard incident routes.
@param \Illuminate\Contracts\Routing\Registrar $router
@return void
|
[
"Define",
"the",
"dashboard",
"incident",
"routes",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Routes/Dashboard/IncidentRoutes.php#L38-L93
|
220,744
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/ComponentGroupController.php
|
ComponentGroupController.index
|
public function index()
{
$groups = ComponentGroup::query();
if (!$this->guard->check()) {
$groups = ComponentGroup::visible();
}
$groups->search(Binput::except(['sort', 'order', 'per_page']));
if ($sortBy = Binput::get('sort')) {
$direction = Binput::get('order', 'asc');
$groups->sort($sortBy, $direction);
}
$groups = $groups->paginate(Binput::get('per_page', 20));
return $this->paginator($groups, Request::instance());
}
|
php
|
public function index()
{
$groups = ComponentGroup::query();
if (!$this->guard->check()) {
$groups = ComponentGroup::visible();
}
$groups->search(Binput::except(['sort', 'order', 'per_page']));
if ($sortBy = Binput::get('sort')) {
$direction = Binput::get('order', 'asc');
$groups->sort($sortBy, $direction);
}
$groups = $groups->paginate(Binput::get('per_page', 20));
return $this->paginator($groups, Request::instance());
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"$",
"groups",
"=",
"ComponentGroup",
"::",
"query",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"guard",
"->",
"check",
"(",
")",
")",
"{",
"$",
"groups",
"=",
"ComponentGroup",
"::",
"visible",
"(",
")",
";",
"}",
"$",
"groups",
"->",
"search",
"(",
"Binput",
"::",
"except",
"(",
"[",
"'sort'",
",",
"'order'",
",",
"'per_page'",
"]",
")",
")",
";",
"if",
"(",
"$",
"sortBy",
"=",
"Binput",
"::",
"get",
"(",
"'sort'",
")",
")",
"{",
"$",
"direction",
"=",
"Binput",
"::",
"get",
"(",
"'order'",
",",
"'asc'",
")",
";",
"$",
"groups",
"->",
"sort",
"(",
"$",
"sortBy",
",",
"$",
"direction",
")",
";",
"}",
"$",
"groups",
"=",
"$",
"groups",
"->",
"paginate",
"(",
"Binput",
"::",
"get",
"(",
"'per_page'",
",",
"20",
")",
")",
";",
"return",
"$",
"this",
"->",
"paginator",
"(",
"$",
"groups",
",",
"Request",
"::",
"instance",
"(",
")",
")",
";",
"}"
] |
Get all groups.
@return \Illuminate\Http\JsonResponse
|
[
"Get",
"all",
"groups",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/ComponentGroupController.php#L55-L73
|
220,745
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/ComponentGroupController.php
|
ComponentGroupController.store
|
public function store()
{
try {
$group = execute(new CreateComponentGroupCommand(
Binput::get('name'),
Binput::get('order', 0),
Binput::get('collapsed', 0),
Binput::get('visible', ComponentGroup::VISIBLE_AUTHENTICATED)
));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->item($group);
}
|
php
|
public function store()
{
try {
$group = execute(new CreateComponentGroupCommand(
Binput::get('name'),
Binput::get('order', 0),
Binput::get('collapsed', 0),
Binput::get('visible', ComponentGroup::VISIBLE_AUTHENTICATED)
));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->item($group);
}
|
[
"public",
"function",
"store",
"(",
")",
"{",
"try",
"{",
"$",
"group",
"=",
"execute",
"(",
"new",
"CreateComponentGroupCommand",
"(",
"Binput",
"::",
"get",
"(",
"'name'",
")",
",",
"Binput",
"::",
"get",
"(",
"'order'",
",",
"0",
")",
",",
"Binput",
"::",
"get",
"(",
"'collapsed'",
",",
"0",
")",
",",
"Binput",
"::",
"get",
"(",
"'visible'",
",",
"ComponentGroup",
"::",
"VISIBLE_AUTHENTICATED",
")",
")",
")",
";",
"}",
"catch",
"(",
"QueryException",
"$",
"e",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"item",
"(",
"$",
"group",
")",
";",
"}"
] |
Create a new component group.
@return \Illuminate\Http\JsonResponse
|
[
"Create",
"a",
"new",
"component",
"group",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/ComponentGroupController.php#L92-L106
|
220,746
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/ComponentGroupController.php
|
ComponentGroupController.update
|
public function update(ComponentGroup $group)
{
try {
$group = execute(new UpdateComponentGroupCommand(
$group,
Binput::get('name'),
Binput::get('order'),
Binput::get('collapsed'),
Binput::get('visible')
));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->item($group);
}
|
php
|
public function update(ComponentGroup $group)
{
try {
$group = execute(new UpdateComponentGroupCommand(
$group,
Binput::get('name'),
Binput::get('order'),
Binput::get('collapsed'),
Binput::get('visible')
));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->item($group);
}
|
[
"public",
"function",
"update",
"(",
"ComponentGroup",
"$",
"group",
")",
"{",
"try",
"{",
"$",
"group",
"=",
"execute",
"(",
"new",
"UpdateComponentGroupCommand",
"(",
"$",
"group",
",",
"Binput",
"::",
"get",
"(",
"'name'",
")",
",",
"Binput",
"::",
"get",
"(",
"'order'",
")",
",",
"Binput",
"::",
"get",
"(",
"'collapsed'",
")",
",",
"Binput",
"::",
"get",
"(",
"'visible'",
")",
")",
")",
";",
"}",
"catch",
"(",
"QueryException",
"$",
"e",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"item",
"(",
"$",
"group",
")",
";",
"}"
] |
Update an existing group.
@param \CachetHQ\Cachet\Models\ComponentGroup $group
@return \Illuminate\Http\JsonResponse
|
[
"Update",
"an",
"existing",
"group",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/ComponentGroupController.php#L115-L130
|
220,747
|
CachetHQ/Cachet
|
app/Repositories/Metric/AbstractMetricRepository.php
|
AbstractMetricRepository.getQueryType
|
protected function getQueryType(Metric $metric)
{
if (!isset($metric->calc_type) || $metric->calc_type == Metric::CALC_SUM) {
return "sum({$this->getMetricPointsTable()}.value * {$this->getMetricPointsTable()}.counter) AS value";
} elseif ($metric->calc_type == Metric::CALC_AVG) {
return "avg({$this->getMetricPointsTable()}.value) AS value";
} else {
return "sum({$this->getMetricPointsTable()}.value * {$this->getMetricPointsTable()}.counter) AS value";
}
}
|
php
|
protected function getQueryType(Metric $metric)
{
if (!isset($metric->calc_type) || $metric->calc_type == Metric::CALC_SUM) {
return "sum({$this->getMetricPointsTable()}.value * {$this->getMetricPointsTable()}.counter) AS value";
} elseif ($metric->calc_type == Metric::CALC_AVG) {
return "avg({$this->getMetricPointsTable()}.value) AS value";
} else {
return "sum({$this->getMetricPointsTable()}.value * {$this->getMetricPointsTable()}.counter) AS value";
}
}
|
[
"protected",
"function",
"getQueryType",
"(",
"Metric",
"$",
"metric",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"metric",
"->",
"calc_type",
")",
"||",
"$",
"metric",
"->",
"calc_type",
"==",
"Metric",
"::",
"CALC_SUM",
")",
"{",
"return",
"\"sum({$this->getMetricPointsTable()}.value * {$this->getMetricPointsTable()}.counter) AS value\"",
";",
"}",
"elseif",
"(",
"$",
"metric",
"->",
"calc_type",
"==",
"Metric",
"::",
"CALC_AVG",
")",
"{",
"return",
"\"avg({$this->getMetricPointsTable()}.value) AS value\"",
";",
"}",
"else",
"{",
"return",
"\"sum({$this->getMetricPointsTable()}.value * {$this->getMetricPointsTable()}.counter) AS value\"",
";",
"}",
"}"
] |
Return the query type.
@param \CachetHQ\Cachet\Models\Metric $metric
@return string
|
[
"Return",
"the",
"query",
"type",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Repositories/Metric/AbstractMetricRepository.php#L83-L92
|
220,748
|
CachetHQ/Cachet
|
app/Repositories/Metric/AbstractMetricRepository.php
|
AbstractMetricRepository.mapResults
|
protected function mapResults(Metric $metric, array $results)
{
$results = Collection::make($results);
return $results->map(function ($point) use ($metric) {
if (!$point->value) {
$point->value = $metric->default_value;
}
if ($point->value === 0 && $metric->default_value != $point->value) {
$point->value = $metric->default_value;
}
$point->value = round($point->value, $metric->places);
return $point;
});
}
|
php
|
protected function mapResults(Metric $metric, array $results)
{
$results = Collection::make($results);
return $results->map(function ($point) use ($metric) {
if (!$point->value) {
$point->value = $metric->default_value;
}
if ($point->value === 0 && $metric->default_value != $point->value) {
$point->value = $metric->default_value;
}
$point->value = round($point->value, $metric->places);
return $point;
});
}
|
[
"protected",
"function",
"mapResults",
"(",
"Metric",
"$",
"metric",
",",
"array",
"$",
"results",
")",
"{",
"$",
"results",
"=",
"Collection",
"::",
"make",
"(",
"$",
"results",
")",
";",
"return",
"$",
"results",
"->",
"map",
"(",
"function",
"(",
"$",
"point",
")",
"use",
"(",
"$",
"metric",
")",
"{",
"if",
"(",
"!",
"$",
"point",
"->",
"value",
")",
"{",
"$",
"point",
"->",
"value",
"=",
"$",
"metric",
"->",
"default_value",
";",
"}",
"if",
"(",
"$",
"point",
"->",
"value",
"===",
"0",
"&&",
"$",
"metric",
"->",
"default_value",
"!=",
"$",
"point",
"->",
"value",
")",
"{",
"$",
"point",
"->",
"value",
"=",
"$",
"metric",
"->",
"default_value",
";",
"}",
"$",
"point",
"->",
"value",
"=",
"round",
"(",
"$",
"point",
"->",
"value",
",",
"$",
"metric",
"->",
"places",
")",
";",
"return",
"$",
"point",
";",
"}",
")",
";",
"}"
] |
Map the result set.
@param \CachetHQ\Cachet\Models\Metric $metric
@param array $results
@return \Illuminate\Support\Collection
|
[
"Map",
"the",
"result",
"set",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Repositories/Metric/AbstractMetricRepository.php#L102-L119
|
220,749
|
CachetHQ/Cachet
|
app/Http/Controllers/SubscribeController.php
|
SubscribeController.postSubscribe
|
public function postSubscribe()
{
$email = Binput::get('email');
$subscriptions = Binput::get('subscriptions');
$verified = app(Repository::class)->get('setting.skip_subscriber_verification');
try {
$subscription = execute(new SubscribeSubscriberCommand($email, $verified));
} catch (ValidationException $e) {
return cachet_redirect('status-page')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))
->withErrors($e->getMessageBag());
}
if ($subscription->is_verified) {
return cachet_redirect('status-page')->withSuccess(trans('cachet.subscriber.email.already-subscribed', ['email' => $email]));
}
return cachet_redirect('subscribe.manage', $subscription->verify_code)
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed')));
}
|
php
|
public function postSubscribe()
{
$email = Binput::get('email');
$subscriptions = Binput::get('subscriptions');
$verified = app(Repository::class)->get('setting.skip_subscriber_verification');
try {
$subscription = execute(new SubscribeSubscriberCommand($email, $verified));
} catch (ValidationException $e) {
return cachet_redirect('status-page')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))
->withErrors($e->getMessageBag());
}
if ($subscription->is_verified) {
return cachet_redirect('status-page')->withSuccess(trans('cachet.subscriber.email.already-subscribed', ['email' => $email]));
}
return cachet_redirect('subscribe.manage', $subscription->verify_code)
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed')));
}
|
[
"public",
"function",
"postSubscribe",
"(",
")",
"{",
"$",
"email",
"=",
"Binput",
"::",
"get",
"(",
"'email'",
")",
";",
"$",
"subscriptions",
"=",
"Binput",
"::",
"get",
"(",
"'subscriptions'",
")",
";",
"$",
"verified",
"=",
"app",
"(",
"Repository",
"::",
"class",
")",
"->",
"get",
"(",
"'setting.skip_subscriber_verification'",
")",
";",
"try",
"{",
"$",
"subscription",
"=",
"execute",
"(",
"new",
"SubscribeSubscriberCommand",
"(",
"$",
"email",
",",
"$",
"verified",
")",
")",
";",
"}",
"catch",
"(",
"ValidationException",
"$",
"e",
")",
"{",
"return",
"cachet_redirect",
"(",
"'status-page'",
")",
"->",
"withInput",
"(",
"Binput",
"::",
"all",
"(",
")",
")",
"->",
"withTitle",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.whoops'",
")",
",",
"trans",
"(",
"'cachet.subscriber.email.failure'",
")",
")",
")",
"->",
"withErrors",
"(",
"$",
"e",
"->",
"getMessageBag",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"subscription",
"->",
"is_verified",
")",
"{",
"return",
"cachet_redirect",
"(",
"'status-page'",
")",
"->",
"withSuccess",
"(",
"trans",
"(",
"'cachet.subscriber.email.already-subscribed'",
",",
"[",
"'email'",
"=>",
"$",
"email",
"]",
")",
")",
";",
"}",
"return",
"cachet_redirect",
"(",
"'subscribe.manage'",
",",
"$",
"subscription",
"->",
"verify_code",
")",
"->",
"withSuccess",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.awesome'",
")",
",",
"trans",
"(",
"'cachet.subscriber.email.subscribed'",
")",
")",
")",
";",
"}"
] |
Handle the subscribe user.
@return \Illuminate\View\View
|
[
"Handle",
"the",
"subscribe",
"user",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/SubscribeController.php#L76-L97
|
220,750
|
CachetHQ/Cachet
|
app/Http/Controllers/SubscribeController.php
|
SubscribeController.getVerify
|
public function getVerify($code = null)
{
if ($code === null) {
throw new NotFoundHttpException();
}
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
if (!$subscriber) {
throw new BadRequestHttpException();
}
if (!$subscriber->is_verified) {
execute(new VerifySubscriberCommand($subscriber));
}
return cachet_redirect('status-page')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.verified')));
}
|
php
|
public function getVerify($code = null)
{
if ($code === null) {
throw new NotFoundHttpException();
}
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
if (!$subscriber) {
throw new BadRequestHttpException();
}
if (!$subscriber->is_verified) {
execute(new VerifySubscriberCommand($subscriber));
}
return cachet_redirect('status-page')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.verified')));
}
|
[
"public",
"function",
"getVerify",
"(",
"$",
"code",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"code",
"===",
"null",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"$",
"subscriber",
"=",
"Subscriber",
"::",
"where",
"(",
"'verify_code'",
",",
"'='",
",",
"$",
"code",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"subscriber",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"subscriber",
"->",
"is_verified",
")",
"{",
"execute",
"(",
"new",
"VerifySubscriberCommand",
"(",
"$",
"subscriber",
")",
")",
";",
"}",
"return",
"cachet_redirect",
"(",
"'status-page'",
")",
"->",
"withSuccess",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.awesome'",
")",
",",
"trans",
"(",
"'cachet.subscriber.email.verified'",
")",
")",
")",
";",
"}"
] |
Handle the verify subscriber email.
@param string|null $code
@return \Illuminate\View\View
|
[
"Handle",
"the",
"verify",
"subscriber",
"email",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/SubscribeController.php#L106-L124
|
220,751
|
CachetHQ/Cachet
|
app/Http/Controllers/SubscribeController.php
|
SubscribeController.getUnsubscribe
|
public function getUnsubscribe($code = null, $subscription = null)
{
if ($code === null) {
throw new NotFoundHttpException();
}
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
if (!$subscriber || !$subscriber->is_verified) {
throw new BadRequestHttpException();
}
if ($subscription) {
execute(new UnsubscribeSubscriptionCommand(Subscription::forSubscriber($subscriber->id)->firstOrFail()));
} else {
execute(new UnsubscribeSubscriberCommand($subscriber));
}
return cachet_redirect('status-page')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.unsubscribed')));
}
|
php
|
public function getUnsubscribe($code = null, $subscription = null)
{
if ($code === null) {
throw new NotFoundHttpException();
}
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
if (!$subscriber || !$subscriber->is_verified) {
throw new BadRequestHttpException();
}
if ($subscription) {
execute(new UnsubscribeSubscriptionCommand(Subscription::forSubscriber($subscriber->id)->firstOrFail()));
} else {
execute(new UnsubscribeSubscriberCommand($subscriber));
}
return cachet_redirect('status-page')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.unsubscribed')));
}
|
[
"public",
"function",
"getUnsubscribe",
"(",
"$",
"code",
"=",
"null",
",",
"$",
"subscription",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"code",
"===",
"null",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"$",
"subscriber",
"=",
"Subscriber",
"::",
"where",
"(",
"'verify_code'",
",",
"'='",
",",
"$",
"code",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"subscriber",
"||",
"!",
"$",
"subscriber",
"->",
"is_verified",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"if",
"(",
"$",
"subscription",
")",
"{",
"execute",
"(",
"new",
"UnsubscribeSubscriptionCommand",
"(",
"Subscription",
"::",
"forSubscriber",
"(",
"$",
"subscriber",
"->",
"id",
")",
"->",
"firstOrFail",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"execute",
"(",
"new",
"UnsubscribeSubscriberCommand",
"(",
"$",
"subscriber",
")",
")",
";",
"}",
"return",
"cachet_redirect",
"(",
"'status-page'",
")",
"->",
"withSuccess",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.awesome'",
")",
",",
"trans",
"(",
"'cachet.subscriber.email.unsubscribed'",
")",
")",
")",
";",
"}"
] |
Handle the unsubscribe.
@param string|null $code
@param int|null $subscription
@return \Illuminate\View\View
|
[
"Handle",
"the",
"unsubscribe",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/SubscribeController.php#L134-L154
|
220,752
|
CachetHQ/Cachet
|
app/Http/Controllers/SubscribeController.php
|
SubscribeController.showManage
|
public function showManage($code = null)
{
if ($code === null) {
throw new NotFoundHttpException();
}
$includePrivate = $this->auth->check();
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
$usedComponentGroups = Component::enabled()->authenticated($includePrivate)->where('group_id', '>', 0)->groupBy('group_id')->pluck('group_id');
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
$ungroupedComponents = Component::enabled()->authenticated($includePrivate)->where('group_id', '=', 0)->orderBy('order')->orderBy('created_at')->get();
if (!$subscriber) {
throw new BadRequestHttpException();
}
return View::make('subscribe.manage')
->withUngroupedComponents($ungroupedComponents)
->withSubscriber($subscriber)
->withSubscriptions($subscriber->subscriptions->pluck('component_id')->all())
->withComponentGroups($componentGroups);
}
|
php
|
public function showManage($code = null)
{
if ($code === null) {
throw new NotFoundHttpException();
}
$includePrivate = $this->auth->check();
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
$usedComponentGroups = Component::enabled()->authenticated($includePrivate)->where('group_id', '>', 0)->groupBy('group_id')->pluck('group_id');
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
$ungroupedComponents = Component::enabled()->authenticated($includePrivate)->where('group_id', '=', 0)->orderBy('order')->orderBy('created_at')->get();
if (!$subscriber) {
throw new BadRequestHttpException();
}
return View::make('subscribe.manage')
->withUngroupedComponents($ungroupedComponents)
->withSubscriber($subscriber)
->withSubscriptions($subscriber->subscriptions->pluck('component_id')->all())
->withComponentGroups($componentGroups);
}
|
[
"public",
"function",
"showManage",
"(",
"$",
"code",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"code",
"===",
"null",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"$",
"includePrivate",
"=",
"$",
"this",
"->",
"auth",
"->",
"check",
"(",
")",
";",
"$",
"subscriber",
"=",
"Subscriber",
"::",
"where",
"(",
"'verify_code'",
",",
"'='",
",",
"$",
"code",
")",
"->",
"first",
"(",
")",
";",
"$",
"usedComponentGroups",
"=",
"Component",
"::",
"enabled",
"(",
")",
"->",
"authenticated",
"(",
"$",
"includePrivate",
")",
"->",
"where",
"(",
"'group_id'",
",",
"'>'",
",",
"0",
")",
"->",
"groupBy",
"(",
"'group_id'",
")",
"->",
"pluck",
"(",
"'group_id'",
")",
";",
"$",
"componentGroups",
"=",
"ComponentGroup",
"::",
"whereIn",
"(",
"'id'",
",",
"$",
"usedComponentGroups",
")",
"->",
"orderBy",
"(",
"'order'",
")",
"->",
"get",
"(",
")",
";",
"$",
"ungroupedComponents",
"=",
"Component",
"::",
"enabled",
"(",
")",
"->",
"authenticated",
"(",
"$",
"includePrivate",
")",
"->",
"where",
"(",
"'group_id'",
",",
"'='",
",",
"0",
")",
"->",
"orderBy",
"(",
"'order'",
")",
"->",
"orderBy",
"(",
"'created_at'",
")",
"->",
"get",
"(",
")",
";",
"if",
"(",
"!",
"$",
"subscriber",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"return",
"View",
"::",
"make",
"(",
"'subscribe.manage'",
")",
"->",
"withUngroupedComponents",
"(",
"$",
"ungroupedComponents",
")",
"->",
"withSubscriber",
"(",
"$",
"subscriber",
")",
"->",
"withSubscriptions",
"(",
"$",
"subscriber",
"->",
"subscriptions",
"->",
"pluck",
"(",
"'component_id'",
")",
"->",
"all",
"(",
")",
")",
"->",
"withComponentGroups",
"(",
"$",
"componentGroups",
")",
";",
"}"
] |
Shows the subscription manager page.
@param string|null $code
@return \Illuminate\View\View
|
[
"Shows",
"the",
"subscription",
"manager",
"page",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/SubscribeController.php#L163-L185
|
220,753
|
CachetHQ/Cachet
|
app/Http/Controllers/SubscribeController.php
|
SubscribeController.postManage
|
public function postManage($code = null)
{
if ($code === null) {
throw new NotFoundHttpException();
}
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
if (!$subscriber) {
throw new BadRequestHttpException();
}
try {
execute(new UpdateSubscriberSubscriptionCommand($subscriber, Binput::get('subscriptions')));
} catch (ValidationException $e) {
return cachet_redirect('subscribe.manage', $subscriber->verify_code)
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))
->withErrors($e->getMessageBag());
}
return cachet_redirect('subscribe.manage', $subscriber->verify_code)
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.updated-subscribe')));
}
|
php
|
public function postManage($code = null)
{
if ($code === null) {
throw new NotFoundHttpException();
}
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
if (!$subscriber) {
throw new BadRequestHttpException();
}
try {
execute(new UpdateSubscriberSubscriptionCommand($subscriber, Binput::get('subscriptions')));
} catch (ValidationException $e) {
return cachet_redirect('subscribe.manage', $subscriber->verify_code)
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))
->withErrors($e->getMessageBag());
}
return cachet_redirect('subscribe.manage', $subscriber->verify_code)
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.updated-subscribe')));
}
|
[
"public",
"function",
"postManage",
"(",
"$",
"code",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"code",
"===",
"null",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"$",
"subscriber",
"=",
"Subscriber",
"::",
"where",
"(",
"'verify_code'",
",",
"'='",
",",
"$",
"code",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"subscriber",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"try",
"{",
"execute",
"(",
"new",
"UpdateSubscriberSubscriptionCommand",
"(",
"$",
"subscriber",
",",
"Binput",
"::",
"get",
"(",
"'subscriptions'",
")",
")",
")",
";",
"}",
"catch",
"(",
"ValidationException",
"$",
"e",
")",
"{",
"return",
"cachet_redirect",
"(",
"'subscribe.manage'",
",",
"$",
"subscriber",
"->",
"verify_code",
")",
"->",
"withInput",
"(",
"Binput",
"::",
"all",
"(",
")",
")",
"->",
"withTitle",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.whoops'",
")",
",",
"trans",
"(",
"'cachet.subscriber.email.failure'",
")",
")",
")",
"->",
"withErrors",
"(",
"$",
"e",
"->",
"getMessageBag",
"(",
")",
")",
";",
"}",
"return",
"cachet_redirect",
"(",
"'subscribe.manage'",
",",
"$",
"subscriber",
"->",
"verify_code",
")",
"->",
"withSuccess",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.awesome'",
")",
",",
"trans",
"(",
"'cachet.subscriber.email.updated-subscribe'",
")",
")",
")",
";",
"}"
] |
Updates the subscription manager for a subscriber.
@param string|null $code
@return \Illuminate\View\View
|
[
"Updates",
"the",
"subscription",
"manager",
"for",
"a",
"subscriber",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/SubscribeController.php#L194-L217
|
220,754
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/User/CreateUserCommandHandler.php
|
CreateUserCommandHandler.handle
|
public function handle(CreateUserCommand $command)
{
$user = User::create([
'username' => $command->username,
'password' => $command->password,
'email' => $command->email,
'level' => $command->level,
]);
event(new UserWasCreatedEvent($user));
return $user;
}
|
php
|
public function handle(CreateUserCommand $command)
{
$user = User::create([
'username' => $command->username,
'password' => $command->password,
'email' => $command->email,
'level' => $command->level,
]);
event(new UserWasCreatedEvent($user));
return $user;
}
|
[
"public",
"function",
"handle",
"(",
"CreateUserCommand",
"$",
"command",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"create",
"(",
"[",
"'username'",
"=>",
"$",
"command",
"->",
"username",
",",
"'password'",
"=>",
"$",
"command",
"->",
"password",
",",
"'email'",
"=>",
"$",
"command",
"->",
"email",
",",
"'level'",
"=>",
"$",
"command",
"->",
"level",
",",
"]",
")",
";",
"event",
"(",
"new",
"UserWasCreatedEvent",
"(",
"$",
"user",
")",
")",
";",
"return",
"$",
"user",
";",
"}"
] |
Handle the add user command.
@param \CachetHQ\Cachet\Bus\Commands\User\CreateUserCommand $command
@return \CachetHQ\Cachet\Models\User
|
[
"Handle",
"the",
"add",
"user",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/User/CreateUserCommandHandler.php#L32-L44
|
220,755
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Schedule/UpdateScheduleCommandHandler.php
|
UpdateScheduleCommandHandler.handle
|
public function handle(UpdateScheduleCommand $command)
{
$schedule = $command->schedule;
$schedule->update($this->filter($command));
event(new ScheduleWasUpdatedEvent($this->auth->user(), $schedule));
return $schedule;
}
|
php
|
public function handle(UpdateScheduleCommand $command)
{
$schedule = $command->schedule;
$schedule->update($this->filter($command));
event(new ScheduleWasUpdatedEvent($this->auth->user(), $schedule));
return $schedule;
}
|
[
"public",
"function",
"handle",
"(",
"UpdateScheduleCommand",
"$",
"command",
")",
"{",
"$",
"schedule",
"=",
"$",
"command",
"->",
"schedule",
";",
"$",
"schedule",
"->",
"update",
"(",
"$",
"this",
"->",
"filter",
"(",
"$",
"command",
")",
")",
";",
"event",
"(",
"new",
"ScheduleWasUpdatedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"schedule",
")",
")",
";",
"return",
"$",
"schedule",
";",
"}"
] |
Handle the update schedule command.
@param \CachetHQ\Cachet\Bus\Commands\Schedule\UpdateScheduleCommand $command
@return \CachetHQ\Cachet\Models\Schedule
|
[
"Handle",
"the",
"update",
"schedule",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Schedule/UpdateScheduleCommandHandler.php#L62-L71
|
220,756
|
CachetHQ/Cachet
|
app/Presenters/SchedulePresenter.php
|
SchedulePresenter.completed_at_datetimepicker
|
public function completed_at_datetimepicker()
{
if ($this->wrappedObject->completed_at) {
return $this->dates->make($this->wrappedObject->completed_at)->format('Y-m-d H:i');
}
}
|
php
|
public function completed_at_datetimepicker()
{
if ($this->wrappedObject->completed_at) {
return $this->dates->make($this->wrappedObject->completed_at)->format('Y-m-d H:i');
}
}
|
[
"public",
"function",
"completed_at_datetimepicker",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"wrappedObject",
"->",
"completed_at",
")",
"{",
"return",
"$",
"this",
"->",
"dates",
"->",
"make",
"(",
"$",
"this",
"->",
"wrappedObject",
"->",
"completed_at",
")",
"->",
"format",
"(",
"'Y-m-d H:i'",
")",
";",
"}",
"}"
] |
Formats the completed_at time ready to be used by bootstrap-datetimepicker.
@return string|void
|
[
"Formats",
"the",
"completed_at",
"time",
"ready",
"to",
"be",
"used",
"by",
"bootstrap",
"-",
"datetimepicker",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Presenters/SchedulePresenter.php#L209-L214
|
220,757
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Component/CreateComponentCommandHandler.php
|
CreateComponentCommandHandler.handle
|
public function handle(CreateComponentCommand $command)
{
$component = Component::create($this->filter($command));
event(new ComponentWasCreatedEvent($this->auth->user(), $component));
return $component;
}
|
php
|
public function handle(CreateComponentCommand $command)
{
$component = Component::create($this->filter($command));
event(new ComponentWasCreatedEvent($this->auth->user(), $component));
return $component;
}
|
[
"public",
"function",
"handle",
"(",
"CreateComponentCommand",
"$",
"command",
")",
"{",
"$",
"component",
"=",
"Component",
"::",
"create",
"(",
"$",
"this",
"->",
"filter",
"(",
"$",
"command",
")",
")",
";",
"event",
"(",
"new",
"ComponentWasCreatedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"component",
")",
")",
";",
"return",
"$",
"component",
";",
"}"
] |
Handle the add component command.
@param \CachetHQ\Cachet\Bus\Commands\Component\CreateComponentCommand $command
@return \CachetHQ\Cachet\Models\Component
|
[
"Handle",
"the",
"add",
"component",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Component/CreateComponentCommandHandler.php#L52-L59
|
220,758
|
CachetHQ/Cachet
|
app/Integrations/Core/Beacon.php
|
Beacon.send
|
public function send()
{
// We don't want any accidental sending of beacons if the installation has explicitly said no.
if (!$this->enabled()) {
return;
}
$setting = app(Setting::class);
if (!$installId = $setting->get('install_id', null)) {
$installId = sha1(Str::random(20));
$setting->set('install_id', $installId);
}
$payload = [
'install_id' => $installId,
'version' => CACHET_VERSION,
'docker' => $this->config->get('cachet.is_docker'),
'database' => $this->config->get('database.default'),
'data' => [
'components' => Component::all()->count(),
'incidents' => Incident::all()->count(),
'metrics' => Metric::all()->count(),
'users' => User::all()->count(),
'actions' => Action::all()->count(),
'tags' => Tag::all()->count(),
'schedules' => Schedule::all()->count(),
],
];
try {
$client = new Client();
$client->post(self::URL, [
'headers' => ['Accept' => 'application/json', 'User-Agent' => defined('CACHET_VERSION') ? 'cachet/'.constant('CACHET_VERSION') : 'cachet'],
'json' => $payload,
]);
} catch (Exception $e) {
event(new BeaconFailedToSendEvent());
return;
}
event(new BeaconWasSentEvent());
}
|
php
|
public function send()
{
// We don't want any accidental sending of beacons if the installation has explicitly said no.
if (!$this->enabled()) {
return;
}
$setting = app(Setting::class);
if (!$installId = $setting->get('install_id', null)) {
$installId = sha1(Str::random(20));
$setting->set('install_id', $installId);
}
$payload = [
'install_id' => $installId,
'version' => CACHET_VERSION,
'docker' => $this->config->get('cachet.is_docker'),
'database' => $this->config->get('database.default'),
'data' => [
'components' => Component::all()->count(),
'incidents' => Incident::all()->count(),
'metrics' => Metric::all()->count(),
'users' => User::all()->count(),
'actions' => Action::all()->count(),
'tags' => Tag::all()->count(),
'schedules' => Schedule::all()->count(),
],
];
try {
$client = new Client();
$client->post(self::URL, [
'headers' => ['Accept' => 'application/json', 'User-Agent' => defined('CACHET_VERSION') ? 'cachet/'.constant('CACHET_VERSION') : 'cachet'],
'json' => $payload,
]);
} catch (Exception $e) {
event(new BeaconFailedToSendEvent());
return;
}
event(new BeaconWasSentEvent());
}
|
[
"public",
"function",
"send",
"(",
")",
"{",
"// We don't want any accidental sending of beacons if the installation has explicitly said no.",
"if",
"(",
"!",
"$",
"this",
"->",
"enabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"setting",
"=",
"app",
"(",
"Setting",
"::",
"class",
")",
";",
"if",
"(",
"!",
"$",
"installId",
"=",
"$",
"setting",
"->",
"get",
"(",
"'install_id'",
",",
"null",
")",
")",
"{",
"$",
"installId",
"=",
"sha1",
"(",
"Str",
"::",
"random",
"(",
"20",
")",
")",
";",
"$",
"setting",
"->",
"set",
"(",
"'install_id'",
",",
"$",
"installId",
")",
";",
"}",
"$",
"payload",
"=",
"[",
"'install_id'",
"=>",
"$",
"installId",
",",
"'version'",
"=>",
"CACHET_VERSION",
",",
"'docker'",
"=>",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'cachet.is_docker'",
")",
",",
"'database'",
"=>",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'database.default'",
")",
",",
"'data'",
"=>",
"[",
"'components'",
"=>",
"Component",
"::",
"all",
"(",
")",
"->",
"count",
"(",
")",
",",
"'incidents'",
"=>",
"Incident",
"::",
"all",
"(",
")",
"->",
"count",
"(",
")",
",",
"'metrics'",
"=>",
"Metric",
"::",
"all",
"(",
")",
"->",
"count",
"(",
")",
",",
"'users'",
"=>",
"User",
"::",
"all",
"(",
")",
"->",
"count",
"(",
")",
",",
"'actions'",
"=>",
"Action",
"::",
"all",
"(",
")",
"->",
"count",
"(",
")",
",",
"'tags'",
"=>",
"Tag",
"::",
"all",
"(",
")",
"->",
"count",
"(",
")",
",",
"'schedules'",
"=>",
"Schedule",
"::",
"all",
"(",
")",
"->",
"count",
"(",
")",
",",
"]",
",",
"]",
";",
"try",
"{",
"$",
"client",
"=",
"new",
"Client",
"(",
")",
";",
"$",
"client",
"->",
"post",
"(",
"self",
"::",
"URL",
",",
"[",
"'headers'",
"=>",
"[",
"'Accept'",
"=>",
"'application/json'",
",",
"'User-Agent'",
"=>",
"defined",
"(",
"'CACHET_VERSION'",
")",
"?",
"'cachet/'",
".",
"constant",
"(",
"'CACHET_VERSION'",
")",
":",
"'cachet'",
"]",
",",
"'json'",
"=>",
"$",
"payload",
",",
"]",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"event",
"(",
"new",
"BeaconFailedToSendEvent",
"(",
")",
")",
";",
"return",
";",
"}",
"event",
"(",
"new",
"BeaconWasSentEvent",
"(",
")",
")",
";",
"}"
] |
Send a beacon to our server.
@return void
|
[
"Send",
"a",
"beacon",
"to",
"our",
"server",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Integrations/Core/Beacon.php#L78-L122
|
220,759
|
CachetHQ/Cachet
|
app/Console/Commands/InstallCommand.php
|
InstallCommand.configureEnvironmentFile
|
protected function configureEnvironmentFile()
{
$dir = app()->environmentPath();
$file = app()->environmentFile();
$path = "{$dir}/{$file}";
if (file_exists($path)) {
$this->line('Environment file already exists. Moving on.');
return;
}
copy("$path.example", $path);
}
|
php
|
protected function configureEnvironmentFile()
{
$dir = app()->environmentPath();
$file = app()->environmentFile();
$path = "{$dir}/{$file}";
if (file_exists($path)) {
$this->line('Environment file already exists. Moving on.');
return;
}
copy("$path.example", $path);
}
|
[
"protected",
"function",
"configureEnvironmentFile",
"(",
")",
"{",
"$",
"dir",
"=",
"app",
"(",
")",
"->",
"environmentPath",
"(",
")",
";",
"$",
"file",
"=",
"app",
"(",
")",
"->",
"environmentFile",
"(",
")",
";",
"$",
"path",
"=",
"\"{$dir}/{$file}\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"'Environment file already exists. Moving on.'",
")",
";",
"return",
";",
"}",
"copy",
"(",
"\"$path.example\"",
",",
"$",
"path",
")",
";",
"}"
] |
Copy the environment file.
@return void
|
[
"Copy",
"the",
"environment",
"file",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/InstallCommand.php#L100-L113
|
220,760
|
CachetHQ/Cachet
|
app/Console/Commands/InstallCommand.php
|
InstallCommand.configureDatabase
|
protected function configureDatabase(array $default = [])
{
$config = array_merge([
'DB_DRIVER' => null,
'DB_HOST' => null,
'DB_DATABASE' => null,
'DB_USERNAME' => null,
'DB_PASSWORD' => null,
'DB_PORT' => null,
'DB_PREFIX' => null,
], $default);
$config['DB_DRIVER'] = $this->choice('Which database driver do you want to use?', [
'mysql' => 'MySQL',
'pgsql' => 'PostgreSQL',
'sqlite' => 'SQLite',
], $config['DB_DRIVER']);
if ($config['DB_DRIVER'] === 'sqlite') {
$config['DB_DATABASE'] = $this->ask('Please provide the full path to your SQLite file.', $config['DB_DATABASE']);
} else {
$config['DB_HOST'] = $this->ask("What is the host of your {$config['DB_DRIVER']} database?", $config['DB_HOST']);
if ($config['DB_HOST'] === 'localhost' && $config['DB_DRIVER'] === 'mysql') {
$this->warn("Using 'localhost' will result in the usage of a local unix socket. Use 127.0.0.1 if you want to connect over TCP");
}
$config['DB_DATABASE'] = $this->ask('What is the name of the database that Cachet should use?', $config['DB_DATABASE']);
$config['DB_USERNAME'] = $this->ask('What username should we connect with?', $config['DB_USERNAME']);
$config['DB_PASSWORD'] = $this->secret('What password should we connect with?', $config['DB_PASSWORD']);
$config['DB_PORT'] = $config['DB_DRIVER'] === 'mysql' ? 3306 : 5432;
if ($this->confirm('Is your database listening on a non-standard port number?')) {
$config['DB_PORT'] = $this->anticipate('What port number is your database using?', [3306, 5432], $config['DB_PORT']);
}
}
if ($this->confirm('Do you want to use a prefix on the table names?')) {
$config['DB_PREFIX'] = $this->ask('Please enter the prefix now...', $config['DB_PREFIX']);
}
// Format the settings ready to display them in the table.
$this->formatConfigsTable($config);
if (!$this->confirm('Are these settings correct?')) {
return $this->configureDatabase($config);
}
foreach ($config as $setting => $value) {
$this->writeEnv($setting, $value);
}
}
|
php
|
protected function configureDatabase(array $default = [])
{
$config = array_merge([
'DB_DRIVER' => null,
'DB_HOST' => null,
'DB_DATABASE' => null,
'DB_USERNAME' => null,
'DB_PASSWORD' => null,
'DB_PORT' => null,
'DB_PREFIX' => null,
], $default);
$config['DB_DRIVER'] = $this->choice('Which database driver do you want to use?', [
'mysql' => 'MySQL',
'pgsql' => 'PostgreSQL',
'sqlite' => 'SQLite',
], $config['DB_DRIVER']);
if ($config['DB_DRIVER'] === 'sqlite') {
$config['DB_DATABASE'] = $this->ask('Please provide the full path to your SQLite file.', $config['DB_DATABASE']);
} else {
$config['DB_HOST'] = $this->ask("What is the host of your {$config['DB_DRIVER']} database?", $config['DB_HOST']);
if ($config['DB_HOST'] === 'localhost' && $config['DB_DRIVER'] === 'mysql') {
$this->warn("Using 'localhost' will result in the usage of a local unix socket. Use 127.0.0.1 if you want to connect over TCP");
}
$config['DB_DATABASE'] = $this->ask('What is the name of the database that Cachet should use?', $config['DB_DATABASE']);
$config['DB_USERNAME'] = $this->ask('What username should we connect with?', $config['DB_USERNAME']);
$config['DB_PASSWORD'] = $this->secret('What password should we connect with?', $config['DB_PASSWORD']);
$config['DB_PORT'] = $config['DB_DRIVER'] === 'mysql' ? 3306 : 5432;
if ($this->confirm('Is your database listening on a non-standard port number?')) {
$config['DB_PORT'] = $this->anticipate('What port number is your database using?', [3306, 5432], $config['DB_PORT']);
}
}
if ($this->confirm('Do you want to use a prefix on the table names?')) {
$config['DB_PREFIX'] = $this->ask('Please enter the prefix now...', $config['DB_PREFIX']);
}
// Format the settings ready to display them in the table.
$this->formatConfigsTable($config);
if (!$this->confirm('Are these settings correct?')) {
return $this->configureDatabase($config);
}
foreach ($config as $setting => $value) {
$this->writeEnv($setting, $value);
}
}
|
[
"protected",
"function",
"configureDatabase",
"(",
"array",
"$",
"default",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"=",
"array_merge",
"(",
"[",
"'DB_DRIVER'",
"=>",
"null",
",",
"'DB_HOST'",
"=>",
"null",
",",
"'DB_DATABASE'",
"=>",
"null",
",",
"'DB_USERNAME'",
"=>",
"null",
",",
"'DB_PASSWORD'",
"=>",
"null",
",",
"'DB_PORT'",
"=>",
"null",
",",
"'DB_PREFIX'",
"=>",
"null",
",",
"]",
",",
"$",
"default",
")",
";",
"$",
"config",
"[",
"'DB_DRIVER'",
"]",
"=",
"$",
"this",
"->",
"choice",
"(",
"'Which database driver do you want to use?'",
",",
"[",
"'mysql'",
"=>",
"'MySQL'",
",",
"'pgsql'",
"=>",
"'PostgreSQL'",
",",
"'sqlite'",
"=>",
"'SQLite'",
",",
"]",
",",
"$",
"config",
"[",
"'DB_DRIVER'",
"]",
")",
";",
"if",
"(",
"$",
"config",
"[",
"'DB_DRIVER'",
"]",
"===",
"'sqlite'",
")",
"{",
"$",
"config",
"[",
"'DB_DATABASE'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'Please provide the full path to your SQLite file.'",
",",
"$",
"config",
"[",
"'DB_DATABASE'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"config",
"[",
"'DB_HOST'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"\"What is the host of your {$config['DB_DRIVER']} database?\"",
",",
"$",
"config",
"[",
"'DB_HOST'",
"]",
")",
";",
"if",
"(",
"$",
"config",
"[",
"'DB_HOST'",
"]",
"===",
"'localhost'",
"&&",
"$",
"config",
"[",
"'DB_DRIVER'",
"]",
"===",
"'mysql'",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Using 'localhost' will result in the usage of a local unix socket. Use 127.0.0.1 if you want to connect over TCP\"",
")",
";",
"}",
"$",
"config",
"[",
"'DB_DATABASE'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'What is the name of the database that Cachet should use?'",
",",
"$",
"config",
"[",
"'DB_DATABASE'",
"]",
")",
";",
"$",
"config",
"[",
"'DB_USERNAME'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'What username should we connect with?'",
",",
"$",
"config",
"[",
"'DB_USERNAME'",
"]",
")",
";",
"$",
"config",
"[",
"'DB_PASSWORD'",
"]",
"=",
"$",
"this",
"->",
"secret",
"(",
"'What password should we connect with?'",
",",
"$",
"config",
"[",
"'DB_PASSWORD'",
"]",
")",
";",
"$",
"config",
"[",
"'DB_PORT'",
"]",
"=",
"$",
"config",
"[",
"'DB_DRIVER'",
"]",
"===",
"'mysql'",
"?",
"3306",
":",
"5432",
";",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"'Is your database listening on a non-standard port number?'",
")",
")",
"{",
"$",
"config",
"[",
"'DB_PORT'",
"]",
"=",
"$",
"this",
"->",
"anticipate",
"(",
"'What port number is your database using?'",
",",
"[",
"3306",
",",
"5432",
"]",
",",
"$",
"config",
"[",
"'DB_PORT'",
"]",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"'Do you want to use a prefix on the table names?'",
")",
")",
"{",
"$",
"config",
"[",
"'DB_PREFIX'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'Please enter the prefix now...'",
",",
"$",
"config",
"[",
"'DB_PREFIX'",
"]",
")",
";",
"}",
"// Format the settings ready to display them in the table.",
"$",
"this",
"->",
"formatConfigsTable",
"(",
"$",
"config",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"confirm",
"(",
"'Are these settings correct?'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configureDatabase",
"(",
"$",
"config",
")",
";",
"}",
"foreach",
"(",
"$",
"config",
"as",
"$",
"setting",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"writeEnv",
"(",
"$",
"setting",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Configure the database.
@param array $default
@return void
|
[
"Configure",
"the",
"database",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/InstallCommand.php#L132-L184
|
220,761
|
CachetHQ/Cachet
|
app/Console/Commands/InstallCommand.php
|
InstallCommand.configureDrivers
|
protected function configureDrivers(array $default = [])
{
$config = array_merge([
'CACHE_DRIVER' => null,
'SESSION_DRIVER' => null,
'QUEUE_DRIVER' => null,
], $default);
// Format the settings ready to display them in the table.
$this->formatConfigsTable($config);
$config['CACHE_DRIVER'] = $this->choice('Which cache driver do you want to use?', [
'apc' => 'APC(u)',
'array' => 'Array',
'database' => 'Database',
'file' => 'File',
'memcached' => 'Memcached',
'redis' => 'Redis',
], $config['CACHE_DRIVER']);
// We need to configure Redis.
if ($config['CACHE_DRIVER'] === 'redis') {
$this->configureRedis();
}
$config['SESSION_DRIVER'] = $this->choice('Which session driver do you want to use?', [
'apc' => 'APC(u)',
'array' => 'Array',
'database' => 'Database',
'file' => 'File',
'memcached' => 'Memcached',
'redis' => 'Redis',
], $config['SESSION_DRIVER']);
// We need to configure Redis.
if ($config['SESSION_DRIVER'] === 'redis') {
$this->configureRedis();
}
$config['QUEUE_DRIVER'] = $this->choice('Which queue driver do you want to use?', [
'null' => 'None',
'sync' => 'Synchronous',
'database' => 'Database',
'beanstalkd' => 'Beanstalk',
'sqs' => 'Amazon SQS',
'redis' => 'Redis',
], $config['QUEUE_DRIVER']);
// We need to configure Redis, but only if the cache driver wasn't redis.
if ($config['QUEUE_DRIVER'] === 'redis' && ($config['SESSION_DRIVER'] !== 'redis' || $config['CACHE_DRIVER'] !== 'redis')) {
$this->configureRedis();
}
// Format the settings ready to display them in the table.
$this->formatConfigsTable($config);
if (!$this->confirm('Are these settings correct?')) {
return $this->configureDrivers($config);
}
foreach ($config as $setting => $value) {
$this->writeEnv($setting, $value);
}
}
|
php
|
protected function configureDrivers(array $default = [])
{
$config = array_merge([
'CACHE_DRIVER' => null,
'SESSION_DRIVER' => null,
'QUEUE_DRIVER' => null,
], $default);
// Format the settings ready to display them in the table.
$this->formatConfigsTable($config);
$config['CACHE_DRIVER'] = $this->choice('Which cache driver do you want to use?', [
'apc' => 'APC(u)',
'array' => 'Array',
'database' => 'Database',
'file' => 'File',
'memcached' => 'Memcached',
'redis' => 'Redis',
], $config['CACHE_DRIVER']);
// We need to configure Redis.
if ($config['CACHE_DRIVER'] === 'redis') {
$this->configureRedis();
}
$config['SESSION_DRIVER'] = $this->choice('Which session driver do you want to use?', [
'apc' => 'APC(u)',
'array' => 'Array',
'database' => 'Database',
'file' => 'File',
'memcached' => 'Memcached',
'redis' => 'Redis',
], $config['SESSION_DRIVER']);
// We need to configure Redis.
if ($config['SESSION_DRIVER'] === 'redis') {
$this->configureRedis();
}
$config['QUEUE_DRIVER'] = $this->choice('Which queue driver do you want to use?', [
'null' => 'None',
'sync' => 'Synchronous',
'database' => 'Database',
'beanstalkd' => 'Beanstalk',
'sqs' => 'Amazon SQS',
'redis' => 'Redis',
], $config['QUEUE_DRIVER']);
// We need to configure Redis, but only if the cache driver wasn't redis.
if ($config['QUEUE_DRIVER'] === 'redis' && ($config['SESSION_DRIVER'] !== 'redis' || $config['CACHE_DRIVER'] !== 'redis')) {
$this->configureRedis();
}
// Format the settings ready to display them in the table.
$this->formatConfigsTable($config);
if (!$this->confirm('Are these settings correct?')) {
return $this->configureDrivers($config);
}
foreach ($config as $setting => $value) {
$this->writeEnv($setting, $value);
}
}
|
[
"protected",
"function",
"configureDrivers",
"(",
"array",
"$",
"default",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"=",
"array_merge",
"(",
"[",
"'CACHE_DRIVER'",
"=>",
"null",
",",
"'SESSION_DRIVER'",
"=>",
"null",
",",
"'QUEUE_DRIVER'",
"=>",
"null",
",",
"]",
",",
"$",
"default",
")",
";",
"// Format the settings ready to display them in the table.",
"$",
"this",
"->",
"formatConfigsTable",
"(",
"$",
"config",
")",
";",
"$",
"config",
"[",
"'CACHE_DRIVER'",
"]",
"=",
"$",
"this",
"->",
"choice",
"(",
"'Which cache driver do you want to use?'",
",",
"[",
"'apc'",
"=>",
"'APC(u)'",
",",
"'array'",
"=>",
"'Array'",
",",
"'database'",
"=>",
"'Database'",
",",
"'file'",
"=>",
"'File'",
",",
"'memcached'",
"=>",
"'Memcached'",
",",
"'redis'",
"=>",
"'Redis'",
",",
"]",
",",
"$",
"config",
"[",
"'CACHE_DRIVER'",
"]",
")",
";",
"// We need to configure Redis.",
"if",
"(",
"$",
"config",
"[",
"'CACHE_DRIVER'",
"]",
"===",
"'redis'",
")",
"{",
"$",
"this",
"->",
"configureRedis",
"(",
")",
";",
"}",
"$",
"config",
"[",
"'SESSION_DRIVER'",
"]",
"=",
"$",
"this",
"->",
"choice",
"(",
"'Which session driver do you want to use?'",
",",
"[",
"'apc'",
"=>",
"'APC(u)'",
",",
"'array'",
"=>",
"'Array'",
",",
"'database'",
"=>",
"'Database'",
",",
"'file'",
"=>",
"'File'",
",",
"'memcached'",
"=>",
"'Memcached'",
",",
"'redis'",
"=>",
"'Redis'",
",",
"]",
",",
"$",
"config",
"[",
"'SESSION_DRIVER'",
"]",
")",
";",
"// We need to configure Redis.",
"if",
"(",
"$",
"config",
"[",
"'SESSION_DRIVER'",
"]",
"===",
"'redis'",
")",
"{",
"$",
"this",
"->",
"configureRedis",
"(",
")",
";",
"}",
"$",
"config",
"[",
"'QUEUE_DRIVER'",
"]",
"=",
"$",
"this",
"->",
"choice",
"(",
"'Which queue driver do you want to use?'",
",",
"[",
"'null'",
"=>",
"'None'",
",",
"'sync'",
"=>",
"'Synchronous'",
",",
"'database'",
"=>",
"'Database'",
",",
"'beanstalkd'",
"=>",
"'Beanstalk'",
",",
"'sqs'",
"=>",
"'Amazon SQS'",
",",
"'redis'",
"=>",
"'Redis'",
",",
"]",
",",
"$",
"config",
"[",
"'QUEUE_DRIVER'",
"]",
")",
";",
"// We need to configure Redis, but only if the cache driver wasn't redis.",
"if",
"(",
"$",
"config",
"[",
"'QUEUE_DRIVER'",
"]",
"===",
"'redis'",
"&&",
"(",
"$",
"config",
"[",
"'SESSION_DRIVER'",
"]",
"!==",
"'redis'",
"||",
"$",
"config",
"[",
"'CACHE_DRIVER'",
"]",
"!==",
"'redis'",
")",
")",
"{",
"$",
"this",
"->",
"configureRedis",
"(",
")",
";",
"}",
"// Format the settings ready to display them in the table.",
"$",
"this",
"->",
"formatConfigsTable",
"(",
"$",
"config",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"confirm",
"(",
"'Are these settings correct?'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configureDrivers",
"(",
"$",
"config",
")",
";",
"}",
"foreach",
"(",
"$",
"config",
"as",
"$",
"setting",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"writeEnv",
"(",
"$",
"setting",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Configure other drivers.
@param array $default
@return void
|
[
"Configure",
"other",
"drivers",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/InstallCommand.php#L193-L256
|
220,762
|
CachetHQ/Cachet
|
app/Console/Commands/InstallCommand.php
|
InstallCommand.configureMail
|
protected function configureMail(array $config = [])
{
$config = array_merge([
'MAIL_DRIVER' => null,
'MAIL_HOST' => null,
'MAIL_PORT' => null,
'MAIL_USERNAME' => null,
'MAIL_PASSWORD' => null,
'MAIL_ADDRESS' => null,
'MAIL_NAME' => null,
'MAIL_ENCRYPTION' => null,
], $config);
// Don't continue with these settings if we're not interested in notifications.
if (!$this->confirm('Do you want Cachet to send mail notifications?')) {
return;
}
$config['MAIL_DRIVER'] = $this->choice('What driver do you want to use to send notifications?', [
'smtp' => 'SMTP',
'mail' => 'Mail',
'sendmail' => 'Sendmail',
'mailgun' => 'Mailgun',
'mandrill' => 'Mandrill',
'ses' => 'Amazon SES',
'sparkpost' => 'SparkPost',
'log' => 'Log (Testing)',
]);
if (!$config['MAIL_DRIVER'] === 'log') {
if ($config['MAIL_DRIVER'] === 'smtp') {
$config['MAIL_HOST'] = $this->ask('Please supply your mail server host');
}
$config['MAIL_ADDRESS'] = $this->ask('What email address should we send notifications from?');
$config['MAIL_USERNAME'] = $this->ask('What username should we connect as?');
$config['MAIL_PASSWORD'] = $this->secret('What password should we connect with?');
}
// Format the settings ready to display them in the table.
$this->formatConfigsTable($config);
if (!$this->confirm('Are these settings correct?')) {
return $this->configureMail($config);
}
foreach ($config as $setting => $value) {
$this->writeEnv($setting, $value);
}
}
|
php
|
protected function configureMail(array $config = [])
{
$config = array_merge([
'MAIL_DRIVER' => null,
'MAIL_HOST' => null,
'MAIL_PORT' => null,
'MAIL_USERNAME' => null,
'MAIL_PASSWORD' => null,
'MAIL_ADDRESS' => null,
'MAIL_NAME' => null,
'MAIL_ENCRYPTION' => null,
], $config);
// Don't continue with these settings if we're not interested in notifications.
if (!$this->confirm('Do you want Cachet to send mail notifications?')) {
return;
}
$config['MAIL_DRIVER'] = $this->choice('What driver do you want to use to send notifications?', [
'smtp' => 'SMTP',
'mail' => 'Mail',
'sendmail' => 'Sendmail',
'mailgun' => 'Mailgun',
'mandrill' => 'Mandrill',
'ses' => 'Amazon SES',
'sparkpost' => 'SparkPost',
'log' => 'Log (Testing)',
]);
if (!$config['MAIL_DRIVER'] === 'log') {
if ($config['MAIL_DRIVER'] === 'smtp') {
$config['MAIL_HOST'] = $this->ask('Please supply your mail server host');
}
$config['MAIL_ADDRESS'] = $this->ask('What email address should we send notifications from?');
$config['MAIL_USERNAME'] = $this->ask('What username should we connect as?');
$config['MAIL_PASSWORD'] = $this->secret('What password should we connect with?');
}
// Format the settings ready to display them in the table.
$this->formatConfigsTable($config);
if (!$this->confirm('Are these settings correct?')) {
return $this->configureMail($config);
}
foreach ($config as $setting => $value) {
$this->writeEnv($setting, $value);
}
}
|
[
"protected",
"function",
"configureMail",
"(",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"=",
"array_merge",
"(",
"[",
"'MAIL_DRIVER'",
"=>",
"null",
",",
"'MAIL_HOST'",
"=>",
"null",
",",
"'MAIL_PORT'",
"=>",
"null",
",",
"'MAIL_USERNAME'",
"=>",
"null",
",",
"'MAIL_PASSWORD'",
"=>",
"null",
",",
"'MAIL_ADDRESS'",
"=>",
"null",
",",
"'MAIL_NAME'",
"=>",
"null",
",",
"'MAIL_ENCRYPTION'",
"=>",
"null",
",",
"]",
",",
"$",
"config",
")",
";",
"// Don't continue with these settings if we're not interested in notifications.",
"if",
"(",
"!",
"$",
"this",
"->",
"confirm",
"(",
"'Do you want Cachet to send mail notifications?'",
")",
")",
"{",
"return",
";",
"}",
"$",
"config",
"[",
"'MAIL_DRIVER'",
"]",
"=",
"$",
"this",
"->",
"choice",
"(",
"'What driver do you want to use to send notifications?'",
",",
"[",
"'smtp'",
"=>",
"'SMTP'",
",",
"'mail'",
"=>",
"'Mail'",
",",
"'sendmail'",
"=>",
"'Sendmail'",
",",
"'mailgun'",
"=>",
"'Mailgun'",
",",
"'mandrill'",
"=>",
"'Mandrill'",
",",
"'ses'",
"=>",
"'Amazon SES'",
",",
"'sparkpost'",
"=>",
"'SparkPost'",
",",
"'log'",
"=>",
"'Log (Testing)'",
",",
"]",
")",
";",
"if",
"(",
"!",
"$",
"config",
"[",
"'MAIL_DRIVER'",
"]",
"===",
"'log'",
")",
"{",
"if",
"(",
"$",
"config",
"[",
"'MAIL_DRIVER'",
"]",
"===",
"'smtp'",
")",
"{",
"$",
"config",
"[",
"'MAIL_HOST'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'Please supply your mail server host'",
")",
";",
"}",
"$",
"config",
"[",
"'MAIL_ADDRESS'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'What email address should we send notifications from?'",
")",
";",
"$",
"config",
"[",
"'MAIL_USERNAME'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'What username should we connect as?'",
")",
";",
"$",
"config",
"[",
"'MAIL_PASSWORD'",
"]",
"=",
"$",
"this",
"->",
"secret",
"(",
"'What password should we connect with?'",
")",
";",
"}",
"// Format the settings ready to display them in the table.",
"$",
"this",
"->",
"formatConfigsTable",
"(",
"$",
"config",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"confirm",
"(",
"'Are these settings correct?'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configureMail",
"(",
"$",
"config",
")",
";",
"}",
"foreach",
"(",
"$",
"config",
"as",
"$",
"setting",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"writeEnv",
"(",
"$",
"setting",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Configure mail.
@param array $config
@return void
|
[
"Configure",
"mail",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/InstallCommand.php#L265-L314
|
220,763
|
CachetHQ/Cachet
|
app/Console/Commands/InstallCommand.php
|
InstallCommand.configureCachet
|
protected function configureCachet(array $config = [])
{
$config = [];
if ($this->confirm('Do you wish to use Cachet Beacon?')) {
$config['CACHET_BEACON'] = 'true';
}
if ($this->confirm('Do you wish to use Emoji? This requires a GitHub oAuth Token!')) {
$config['GITHUB_TOKEN'] = $this->ask('Please enter your GitHub oAuth Token');
$config['CACHET_EMOJI'] = 'true';
}
foreach ($config as $setting => $value) {
$this->writeEnv($setting, $value);
}
}
|
php
|
protected function configureCachet(array $config = [])
{
$config = [];
if ($this->confirm('Do you wish to use Cachet Beacon?')) {
$config['CACHET_BEACON'] = 'true';
}
if ($this->confirm('Do you wish to use Emoji? This requires a GitHub oAuth Token!')) {
$config['GITHUB_TOKEN'] = $this->ask('Please enter your GitHub oAuth Token');
$config['CACHET_EMOJI'] = 'true';
}
foreach ($config as $setting => $value) {
$this->writeEnv($setting, $value);
}
}
|
[
"protected",
"function",
"configureCachet",
"(",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"'Do you wish to use Cachet Beacon?'",
")",
")",
"{",
"$",
"config",
"[",
"'CACHET_BEACON'",
"]",
"=",
"'true'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"'Do you wish to use Emoji? This requires a GitHub oAuth Token!'",
")",
")",
"{",
"$",
"config",
"[",
"'GITHUB_TOKEN'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'Please enter your GitHub oAuth Token'",
")",
";",
"$",
"config",
"[",
"'CACHET_EMOJI'",
"]",
"=",
"'true'",
";",
"}",
"foreach",
"(",
"$",
"config",
"as",
"$",
"setting",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"writeEnv",
"(",
"$",
"setting",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Configure Cachet.
@param array $config
@return void
|
[
"Configure",
"Cachet",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/InstallCommand.php#L323-L338
|
220,764
|
CachetHQ/Cachet
|
app/Console/Commands/InstallCommand.php
|
InstallCommand.configureUser
|
protected function configureUser()
{
if (!$this->confirm('Do you want to create an admin user?')) {
return;
}
// We need to refresh the config to get access to the newly connected database.
$this->getFreshConfiguration();
// Now we need to install the application.
// $this->call('cachet:install');
$user = [
'username' => $this->ask('Please enter your username'),
'email' => $this->ask('Please enter your email'),
'password' => $this->secret('Please enter your password'),
'level' => User::LEVEL_ADMIN,
];
User::create($user);
}
|
php
|
protected function configureUser()
{
if (!$this->confirm('Do you want to create an admin user?')) {
return;
}
// We need to refresh the config to get access to the newly connected database.
$this->getFreshConfiguration();
// Now we need to install the application.
// $this->call('cachet:install');
$user = [
'username' => $this->ask('Please enter your username'),
'email' => $this->ask('Please enter your email'),
'password' => $this->secret('Please enter your password'),
'level' => User::LEVEL_ADMIN,
];
User::create($user);
}
|
[
"protected",
"function",
"configureUser",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"confirm",
"(",
"'Do you want to create an admin user?'",
")",
")",
"{",
"return",
";",
"}",
"// We need to refresh the config to get access to the newly connected database.",
"$",
"this",
"->",
"getFreshConfiguration",
"(",
")",
";",
"// Now we need to install the application.",
"// $this->call('cachet:install');",
"$",
"user",
"=",
"[",
"'username'",
"=>",
"$",
"this",
"->",
"ask",
"(",
"'Please enter your username'",
")",
",",
"'email'",
"=>",
"$",
"this",
"->",
"ask",
"(",
"'Please enter your email'",
")",
",",
"'password'",
"=>",
"$",
"this",
"->",
"secret",
"(",
"'Please enter your password'",
")",
",",
"'level'",
"=>",
"User",
"::",
"LEVEL_ADMIN",
",",
"]",
";",
"User",
"::",
"create",
"(",
"$",
"user",
")",
";",
"}"
] |
Configure the first user.
@return void
|
[
"Configure",
"the",
"first",
"user",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/InstallCommand.php#L345-L365
|
220,765
|
CachetHQ/Cachet
|
app/Console/Commands/InstallCommand.php
|
InstallCommand.configureRedis
|
protected function configureRedis()
{
$config = [
'REDIS_HOST' => null,
'REDIS_DATABASE' => null,
'REDIS_PORT' => null,
];
$config['REDIS_HOST'] = $this->ask('What is the host of your redis server?');
$config['REDIS_DATABASE'] = $this->ask('What is the name of the database that Cachet should use?');
$config['REDIS_PORT'] = $this->ask('What port should Cachet use?', 6379);
foreach ($config as $setting => $value) {
$this->writeEnv($setting, $value);
}
}
|
php
|
protected function configureRedis()
{
$config = [
'REDIS_HOST' => null,
'REDIS_DATABASE' => null,
'REDIS_PORT' => null,
];
$config['REDIS_HOST'] = $this->ask('What is the host of your redis server?');
$config['REDIS_DATABASE'] = $this->ask('What is the name of the database that Cachet should use?');
$config['REDIS_PORT'] = $this->ask('What port should Cachet use?', 6379);
foreach ($config as $setting => $value) {
$this->writeEnv($setting, $value);
}
}
|
[
"protected",
"function",
"configureRedis",
"(",
")",
"{",
"$",
"config",
"=",
"[",
"'REDIS_HOST'",
"=>",
"null",
",",
"'REDIS_DATABASE'",
"=>",
"null",
",",
"'REDIS_PORT'",
"=>",
"null",
",",
"]",
";",
"$",
"config",
"[",
"'REDIS_HOST'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'What is the host of your redis server?'",
")",
";",
"$",
"config",
"[",
"'REDIS_DATABASE'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'What is the name of the database that Cachet should use?'",
")",
";",
"$",
"config",
"[",
"'REDIS_PORT'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'What port should Cachet use?'",
",",
"6379",
")",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"setting",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"writeEnv",
"(",
"$",
"setting",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Configure the redis connection.
@return void
|
[
"Configure",
"the",
"redis",
"connection",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/InstallCommand.php#L372-L387
|
220,766
|
CachetHQ/Cachet
|
app/Console/Commands/InstallCommand.php
|
InstallCommand.formatConfigsTable
|
protected function formatConfigsTable(array $config)
{
$configRows = [];
foreach ($config as $setting => $value) {
$configRows[] = compact('setting', 'value');
}
$this->table(['Setting', 'Value'], $configRows);
}
|
php
|
protected function formatConfigsTable(array $config)
{
$configRows = [];
foreach ($config as $setting => $value) {
$configRows[] = compact('setting', 'value');
}
$this->table(['Setting', 'Value'], $configRows);
}
|
[
"protected",
"function",
"formatConfigsTable",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"configRows",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"setting",
"=>",
"$",
"value",
")",
"{",
"$",
"configRows",
"[",
"]",
"=",
"compact",
"(",
"'setting'",
",",
"'value'",
")",
";",
"}",
"$",
"this",
"->",
"table",
"(",
"[",
"'Setting'",
",",
"'Value'",
"]",
",",
"$",
"configRows",
")",
";",
"}"
] |
Format the configs into a pretty table that we can easily read.
@param array $config
@return void
|
[
"Format",
"the",
"configs",
"into",
"a",
"pretty",
"table",
"that",
"we",
"can",
"easily",
"read",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/InstallCommand.php#L396-L405
|
220,767
|
CachetHQ/Cachet
|
app/Http/Controllers/Dashboard/TeamController.php
|
TeamController.showTeamView
|
public function showTeamView()
{
$team = User::all();
return View::make('dashboard.team.index')
->withPageTitle(trans('dashboard.team.team').' - '.trans('dashboard.dashboard'))
->withTeamMembers($team);
}
|
php
|
public function showTeamView()
{
$team = User::all();
return View::make('dashboard.team.index')
->withPageTitle(trans('dashboard.team.team').' - '.trans('dashboard.dashboard'))
->withTeamMembers($team);
}
|
[
"public",
"function",
"showTeamView",
"(",
")",
"{",
"$",
"team",
"=",
"User",
"::",
"all",
"(",
")",
";",
"return",
"View",
"::",
"make",
"(",
"'dashboard.team.index'",
")",
"->",
"withPageTitle",
"(",
"trans",
"(",
"'dashboard.team.team'",
")",
".",
"' - '",
".",
"trans",
"(",
"'dashboard.dashboard'",
")",
")",
"->",
"withTeamMembers",
"(",
"$",
"team",
")",
";",
"}"
] |
Shows the team members view.
@return \Illuminate\View\View
|
[
"Shows",
"the",
"team",
"members",
"view",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/TeamController.php#L30-L37
|
220,768
|
CachetHQ/Cachet
|
app/Http/Controllers/Dashboard/TeamController.php
|
TeamController.showTeamMemberView
|
public function showTeamMemberView(User $user)
{
return View::make('dashboard.team.edit')
->withPageTitle(trans('dashboard.team.edit.title').' - '.trans('dashboard.dashboard'))
->withUser($user);
}
|
php
|
public function showTeamMemberView(User $user)
{
return View::make('dashboard.team.edit')
->withPageTitle(trans('dashboard.team.edit.title').' - '.trans('dashboard.dashboard'))
->withUser($user);
}
|
[
"public",
"function",
"showTeamMemberView",
"(",
"User",
"$",
"user",
")",
"{",
"return",
"View",
"::",
"make",
"(",
"'dashboard.team.edit'",
")",
"->",
"withPageTitle",
"(",
"trans",
"(",
"'dashboard.team.edit.title'",
")",
".",
"' - '",
".",
"trans",
"(",
"'dashboard.dashboard'",
")",
")",
"->",
"withUser",
"(",
"$",
"user",
")",
";",
"}"
] |
Shows the edit team member view.
@param \CachetHQ\Cachet\Models\User $user
@return \Illuminate\View\View
|
[
"Shows",
"the",
"edit",
"team",
"member",
"view",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/TeamController.php#L46-L51
|
220,769
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/AbstractApiController.php
|
AbstractApiController.paginator
|
protected function paginator(Paginator $paginator, Request $request)
{
foreach ($request->query as $key => $value) {
if ($key != 'page') {
$paginator->appends($key, $value);
}
}
$pagination = [
'pagination' => [
'total' => (int) $paginator->total(),
'count' => count($paginator->items()),
'per_page' => (int) $paginator->perPage(),
'current_page' => (int) $paginator->currentPage(),
'total_pages' => (int) $paginator->lastPage(),
'links' => [
'next_page' => $paginator->nextPageUrl(),
'previous_page' => $paginator->previousPageUrl(),
],
],
];
$items = $paginator->getCollection();
return $this->setMetaData($pagination)->setData(AutoPresenter::decorate($items->values()))->respond();
}
|
php
|
protected function paginator(Paginator $paginator, Request $request)
{
foreach ($request->query as $key => $value) {
if ($key != 'page') {
$paginator->appends($key, $value);
}
}
$pagination = [
'pagination' => [
'total' => (int) $paginator->total(),
'count' => count($paginator->items()),
'per_page' => (int) $paginator->perPage(),
'current_page' => (int) $paginator->currentPage(),
'total_pages' => (int) $paginator->lastPage(),
'links' => [
'next_page' => $paginator->nextPageUrl(),
'previous_page' => $paginator->previousPageUrl(),
],
],
];
$items = $paginator->getCollection();
return $this->setMetaData($pagination)->setData(AutoPresenter::decorate($items->values()))->respond();
}
|
[
"protected",
"function",
"paginator",
"(",
"Paginator",
"$",
"paginator",
",",
"Request",
"$",
"request",
")",
"{",
"foreach",
"(",
"$",
"request",
"->",
"query",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"!=",
"'page'",
")",
"{",
"$",
"paginator",
"->",
"appends",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"$",
"pagination",
"=",
"[",
"'pagination'",
"=>",
"[",
"'total'",
"=>",
"(",
"int",
")",
"$",
"paginator",
"->",
"total",
"(",
")",
",",
"'count'",
"=>",
"count",
"(",
"$",
"paginator",
"->",
"items",
"(",
")",
")",
",",
"'per_page'",
"=>",
"(",
"int",
")",
"$",
"paginator",
"->",
"perPage",
"(",
")",
",",
"'current_page'",
"=>",
"(",
"int",
")",
"$",
"paginator",
"->",
"currentPage",
"(",
")",
",",
"'total_pages'",
"=>",
"(",
"int",
")",
"$",
"paginator",
"->",
"lastPage",
"(",
")",
",",
"'links'",
"=>",
"[",
"'next_page'",
"=>",
"$",
"paginator",
"->",
"nextPageUrl",
"(",
")",
",",
"'previous_page'",
"=>",
"$",
"paginator",
"->",
"previousPageUrl",
"(",
")",
",",
"]",
",",
"]",
",",
"]",
";",
"$",
"items",
"=",
"$",
"paginator",
"->",
"getCollection",
"(",
")",
";",
"return",
"$",
"this",
"->",
"setMetaData",
"(",
"$",
"pagination",
")",
"->",
"setData",
"(",
"AutoPresenter",
"::",
"decorate",
"(",
"$",
"items",
"->",
"values",
"(",
")",
")",
")",
"->",
"respond",
"(",
")",
";",
"}"
] |
Respond with a pagination response.
@param \Illuminate\Pagination\Paginator $paginator
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\JsonResponse
|
[
"Respond",
"with",
"a",
"pagination",
"response",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/AbstractApiController.php#L140-L165
|
220,770
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/AbstractApiController.php
|
AbstractApiController.respond
|
protected function respond()
{
$response = [];
if (!empty($this->meta)) {
$response['meta'] = $this->meta;
}
$response['data'] = $this->data;
if ($this->data instanceof Arrayable) {
$response['data'] = $this->data->toArray();
}
return Response::json($response, $this->statusCode, $this->headers);
}
|
php
|
protected function respond()
{
$response = [];
if (!empty($this->meta)) {
$response['meta'] = $this->meta;
}
$response['data'] = $this->data;
if ($this->data instanceof Arrayable) {
$response['data'] = $this->data->toArray();
}
return Response::json($response, $this->statusCode, $this->headers);
}
|
[
"protected",
"function",
"respond",
"(",
")",
"{",
"$",
"response",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"meta",
")",
")",
"{",
"$",
"response",
"[",
"'meta'",
"]",
"=",
"$",
"this",
"->",
"meta",
";",
"}",
"$",
"response",
"[",
"'data'",
"]",
"=",
"$",
"this",
"->",
"data",
";",
"if",
"(",
"$",
"this",
"->",
"data",
"instanceof",
"Arrayable",
")",
"{",
"$",
"response",
"[",
"'data'",
"]",
"=",
"$",
"this",
"->",
"data",
"->",
"toArray",
"(",
")",
";",
"}",
"return",
"Response",
"::",
"json",
"(",
"$",
"response",
",",
"$",
"this",
"->",
"statusCode",
",",
"$",
"this",
"->",
"headers",
")",
";",
"}"
] |
Build the response.
@return \Illuminate\Http\Response
|
[
"Build",
"the",
"response",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/AbstractApiController.php#L182-L197
|
220,771
|
CachetHQ/Cachet
|
app/Services/Dates/DateFactory.php
|
DateFactory.getTimezone
|
public function getTimezone()
{
$dateTime = new Date();
$dateTime->setTimeZone(new DateTimeZone($this->cachetTimezone));
return $dateTime->format('T');
}
|
php
|
public function getTimezone()
{
$dateTime = new Date();
$dateTime->setTimeZone(new DateTimeZone($this->cachetTimezone));
return $dateTime->format('T');
}
|
[
"public",
"function",
"getTimezone",
"(",
")",
"{",
"$",
"dateTime",
"=",
"new",
"Date",
"(",
")",
";",
"$",
"dateTime",
"->",
"setTimeZone",
"(",
"new",
"DateTimeZone",
"(",
"$",
"this",
"->",
"cachetTimezone",
")",
")",
";",
"return",
"$",
"dateTime",
"->",
"format",
"(",
"'T'",
")",
";",
"}"
] |
Return the abbreviated timezone.
@return string
|
[
"Return",
"the",
"abbreviated",
"timezone",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Services/Dates/DateFactory.php#L104-L110
|
220,772
|
CachetHQ/Cachet
|
app/Composers/AppComposer.php
|
AppComposer.compose
|
public function compose(View $view)
{
$view->withAboutApp(Markdown::convertToHtml($this->config->get('setting.app_about')));
$view->withAppAnalytics($this->config->get('setting.app_analytics'));
$view->withAppAnalyticsGoSquared($this->config->get('setting.app_analytics_gs'));
$view->withAppAnalyticsPiwikUrl($this->config->get('setting.app_analytics_piwik_url'));
$view->withAppAnalyticsPiwikSiteId($this->config->get('setting.app_analytics_piwik_site_id'));
$view->withAppBanner($this->config->get('setting.app_banner'));
$view->withAppBannerStyleFullWidth($this->config->get('setting.style_fullwidth_header'));
$view->withAppBannerType($this->config->get('setting.app_banner_type'));
$view->withAppDomain($this->config->get('setting.app_domain'));
$view->withAppGraphs($this->config->get('setting.display_graphs'));
$view->withAppLocale($this->config->get('setting.app_locale'));
$view->withAppStylesheet($this->config->get('setting.stylesheet'));
$view->withAppUrl($this->config->get('app.url'));
$view->withAppHeader($this->config->get('setting.header'));
$view->withAppFooter($this->config->get('setting.footer'));
$view->withAppName($this->config->get('setting.app_name'));
$view->withShowSupport($this->config->get('setting.show_support'));
$view->withAutomaticLocalization($this->config->get('setting.automatic_localization'));
$view->withEnableExternalDependencies($this->config->get('setting.enable_external_dependencies'));
$view->withShowTimezone($this->config->get('setting.show_timezone'));
$view->withAppRefreshRate($this->config->get('setting.app_refresh_rate'));
$view->withTimezone($this->dates->getTimezone());
$view->withSiteTitle($this->config->get('setting.app_name'));
$view->withFontSubset($this->config->get('langs.'.$this->config->get('app.locale').'.subset', 'latin'));
$view->withOnlyDisruptedDays($this->config->get('setting.only_disrupted_days'));
$view->withDashboardLink($this->config->get('setting.dashboard_login_link'));
$view->withEnableSubscribers($this->config->get('setting.enable_subscribers'));
}
|
php
|
public function compose(View $view)
{
$view->withAboutApp(Markdown::convertToHtml($this->config->get('setting.app_about')));
$view->withAppAnalytics($this->config->get('setting.app_analytics'));
$view->withAppAnalyticsGoSquared($this->config->get('setting.app_analytics_gs'));
$view->withAppAnalyticsPiwikUrl($this->config->get('setting.app_analytics_piwik_url'));
$view->withAppAnalyticsPiwikSiteId($this->config->get('setting.app_analytics_piwik_site_id'));
$view->withAppBanner($this->config->get('setting.app_banner'));
$view->withAppBannerStyleFullWidth($this->config->get('setting.style_fullwidth_header'));
$view->withAppBannerType($this->config->get('setting.app_banner_type'));
$view->withAppDomain($this->config->get('setting.app_domain'));
$view->withAppGraphs($this->config->get('setting.display_graphs'));
$view->withAppLocale($this->config->get('setting.app_locale'));
$view->withAppStylesheet($this->config->get('setting.stylesheet'));
$view->withAppUrl($this->config->get('app.url'));
$view->withAppHeader($this->config->get('setting.header'));
$view->withAppFooter($this->config->get('setting.footer'));
$view->withAppName($this->config->get('setting.app_name'));
$view->withShowSupport($this->config->get('setting.show_support'));
$view->withAutomaticLocalization($this->config->get('setting.automatic_localization'));
$view->withEnableExternalDependencies($this->config->get('setting.enable_external_dependencies'));
$view->withShowTimezone($this->config->get('setting.show_timezone'));
$view->withAppRefreshRate($this->config->get('setting.app_refresh_rate'));
$view->withTimezone($this->dates->getTimezone());
$view->withSiteTitle($this->config->get('setting.app_name'));
$view->withFontSubset($this->config->get('langs.'.$this->config->get('app.locale').'.subset', 'latin'));
$view->withOnlyDisruptedDays($this->config->get('setting.only_disrupted_days'));
$view->withDashboardLink($this->config->get('setting.dashboard_login_link'));
$view->withEnableSubscribers($this->config->get('setting.enable_subscribers'));
}
|
[
"public",
"function",
"compose",
"(",
"View",
"$",
"view",
")",
"{",
"$",
"view",
"->",
"withAboutApp",
"(",
"Markdown",
"::",
"convertToHtml",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.app_about'",
")",
")",
")",
";",
"$",
"view",
"->",
"withAppAnalytics",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.app_analytics'",
")",
")",
";",
"$",
"view",
"->",
"withAppAnalyticsGoSquared",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.app_analytics_gs'",
")",
")",
";",
"$",
"view",
"->",
"withAppAnalyticsPiwikUrl",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.app_analytics_piwik_url'",
")",
")",
";",
"$",
"view",
"->",
"withAppAnalyticsPiwikSiteId",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.app_analytics_piwik_site_id'",
")",
")",
";",
"$",
"view",
"->",
"withAppBanner",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.app_banner'",
")",
")",
";",
"$",
"view",
"->",
"withAppBannerStyleFullWidth",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.style_fullwidth_header'",
")",
")",
";",
"$",
"view",
"->",
"withAppBannerType",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.app_banner_type'",
")",
")",
";",
"$",
"view",
"->",
"withAppDomain",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.app_domain'",
")",
")",
";",
"$",
"view",
"->",
"withAppGraphs",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.display_graphs'",
")",
")",
";",
"$",
"view",
"->",
"withAppLocale",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.app_locale'",
")",
")",
";",
"$",
"view",
"->",
"withAppStylesheet",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.stylesheet'",
")",
")",
";",
"$",
"view",
"->",
"withAppUrl",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'app.url'",
")",
")",
";",
"$",
"view",
"->",
"withAppHeader",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.header'",
")",
")",
";",
"$",
"view",
"->",
"withAppFooter",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.footer'",
")",
")",
";",
"$",
"view",
"->",
"withAppName",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.app_name'",
")",
")",
";",
"$",
"view",
"->",
"withShowSupport",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.show_support'",
")",
")",
";",
"$",
"view",
"->",
"withAutomaticLocalization",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.automatic_localization'",
")",
")",
";",
"$",
"view",
"->",
"withEnableExternalDependencies",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.enable_external_dependencies'",
")",
")",
";",
"$",
"view",
"->",
"withShowTimezone",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.show_timezone'",
")",
")",
";",
"$",
"view",
"->",
"withAppRefreshRate",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.app_refresh_rate'",
")",
")",
";",
"$",
"view",
"->",
"withTimezone",
"(",
"$",
"this",
"->",
"dates",
"->",
"getTimezone",
"(",
")",
")",
";",
"$",
"view",
"->",
"withSiteTitle",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.app_name'",
")",
")",
";",
"$",
"view",
"->",
"withFontSubset",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'langs.'",
".",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'app.locale'",
")",
".",
"'.subset'",
",",
"'latin'",
")",
")",
";",
"$",
"view",
"->",
"withOnlyDisruptedDays",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.only_disrupted_days'",
")",
")",
";",
"$",
"view",
"->",
"withDashboardLink",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.dashboard_login_link'",
")",
")",
";",
"$",
"view",
"->",
"withEnableSubscribers",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'setting.enable_subscribers'",
")",
")",
";",
"}"
] |
Index page view composer.
@param \Illuminate\Contracts\View\View $view
@return void
|
[
"Index",
"page",
"view",
"composer",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Composers/AppComposer.php#L62-L91
|
220,773
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/IncidentUpdateController.php
|
IncidentUpdateController.index
|
public function index(Incident $incident)
{
$updates = $incident->updates()->orderBy('created_at', 'desc');
if ($sortBy = Binput::get('sort')) {
$direction = Binput::has('order') && Binput::get('order') == 'desc';
$updates->sort($sortBy, $direction);
}
$updates = $updates->paginate(Binput::get('per_page', 20));
return $this->paginator($updates, Request::instance());
}
|
php
|
public function index(Incident $incident)
{
$updates = $incident->updates()->orderBy('created_at', 'desc');
if ($sortBy = Binput::get('sort')) {
$direction = Binput::has('order') && Binput::get('order') == 'desc';
$updates->sort($sortBy, $direction);
}
$updates = $updates->paginate(Binput::get('per_page', 20));
return $this->paginator($updates, Request::instance());
}
|
[
"public",
"function",
"index",
"(",
"Incident",
"$",
"incident",
")",
"{",
"$",
"updates",
"=",
"$",
"incident",
"->",
"updates",
"(",
")",
"->",
"orderBy",
"(",
"'created_at'",
",",
"'desc'",
")",
";",
"if",
"(",
"$",
"sortBy",
"=",
"Binput",
"::",
"get",
"(",
"'sort'",
")",
")",
"{",
"$",
"direction",
"=",
"Binput",
"::",
"has",
"(",
"'order'",
")",
"&&",
"Binput",
"::",
"get",
"(",
"'order'",
")",
"==",
"'desc'",
";",
"$",
"updates",
"->",
"sort",
"(",
"$",
"sortBy",
",",
"$",
"direction",
")",
";",
"}",
"$",
"updates",
"=",
"$",
"updates",
"->",
"paginate",
"(",
"Binput",
"::",
"get",
"(",
"'per_page'",
",",
"20",
")",
")",
";",
"return",
"$",
"this",
"->",
"paginator",
"(",
"$",
"updates",
",",
"Request",
"::",
"instance",
"(",
")",
")",
";",
"}"
] |
Return all updates on the incident.
@param \CachetHQ\Cachet\Models\Incident $incident
@return \Illuminate\Http\JsonResponse
|
[
"Return",
"all",
"updates",
"on",
"the",
"incident",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/IncidentUpdateController.php#L39-L52
|
220,774
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/IncidentUpdateController.php
|
IncidentUpdateController.update
|
public function update(Incident $incident, IncidentUpdate $update)
{
try {
$update = execute(new UpdateIncidentUpdateCommand(
$update,
Binput::get('status'),
Binput::get('message'),
Auth::user()
));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->item($update);
}
|
php
|
public function update(Incident $incident, IncidentUpdate $update)
{
try {
$update = execute(new UpdateIncidentUpdateCommand(
$update,
Binput::get('status'),
Binput::get('message'),
Auth::user()
));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
return $this->item($update);
}
|
[
"public",
"function",
"update",
"(",
"Incident",
"$",
"incident",
",",
"IncidentUpdate",
"$",
"update",
")",
"{",
"try",
"{",
"$",
"update",
"=",
"execute",
"(",
"new",
"UpdateIncidentUpdateCommand",
"(",
"$",
"update",
",",
"Binput",
"::",
"get",
"(",
"'status'",
")",
",",
"Binput",
"::",
"get",
"(",
"'message'",
")",
",",
"Auth",
"::",
"user",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"QueryException",
"$",
"e",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"item",
"(",
"$",
"update",
")",
";",
"}"
] |
Update an incident update.
@param \CachetHQ\Cachet\Models\Incident $incident
@param \CachetHQ\Cachet\Models\IncidentUpdate $update
@return \Illuminate\Http\JsonResponse
|
[
"Update",
"an",
"incident",
"update",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/IncidentUpdateController.php#L100-L114
|
220,775
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/IncidentTemplateController.php
|
IncidentTemplateController.index
|
public function index()
{
$templates = IncidentTemplate::query();
if ($sortBy = Binput::get('sort')) {
$direction = Binput::has('order') && Binput::get('order') == 'desc';
$templates->sort($sortBy, $direction);
}
$templates = $templates->paginate(Binput::get('per_page', 20));
return $this->paginator($templates, Request::instance());
}
|
php
|
public function index()
{
$templates = IncidentTemplate::query();
if ($sortBy = Binput::get('sort')) {
$direction = Binput::has('order') && Binput::get('order') == 'desc';
$templates->sort($sortBy, $direction);
}
$templates = $templates->paginate(Binput::get('per_page', 20));
return $this->paginator($templates, Request::instance());
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"$",
"templates",
"=",
"IncidentTemplate",
"::",
"query",
"(",
")",
";",
"if",
"(",
"$",
"sortBy",
"=",
"Binput",
"::",
"get",
"(",
"'sort'",
")",
")",
"{",
"$",
"direction",
"=",
"Binput",
"::",
"has",
"(",
"'order'",
")",
"&&",
"Binput",
"::",
"get",
"(",
"'order'",
")",
"==",
"'desc'",
";",
"$",
"templates",
"->",
"sort",
"(",
"$",
"sortBy",
",",
"$",
"direction",
")",
";",
"}",
"$",
"templates",
"=",
"$",
"templates",
"->",
"paginate",
"(",
"Binput",
"::",
"get",
"(",
"'per_page'",
",",
"20",
")",
")",
";",
"return",
"$",
"this",
"->",
"paginator",
"(",
"$",
"templates",
",",
"Request",
"::",
"instance",
"(",
")",
")",
";",
"}"
] |
Get all incident templates.
@return \Illuminate\Http\JsonResponse
|
[
"Get",
"all",
"incident",
"templates",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/IncidentTemplateController.php#L25-L38
|
220,776
|
CachetHQ/Cachet
|
app/Models/Subscription.php
|
Subscription.scopeIsVerifiedForComponent
|
public function scopeIsVerifiedForComponent(Builder $query, $component_id)
{
return $query->select('subscriptions.*')
->join('subscribers', 'subscriptions.subscriber_id', '=', 'subscribers.id')
->where(function ($query) {
$query->where('subscriptions.component_id', '=', $component_id)
->orWhere('subscribers.global');
})
->whereNotNull('subscribers.verified_at');
}
|
php
|
public function scopeIsVerifiedForComponent(Builder $query, $component_id)
{
return $query->select('subscriptions.*')
->join('subscribers', 'subscriptions.subscriber_id', '=', 'subscribers.id')
->where(function ($query) {
$query->where('subscriptions.component_id', '=', $component_id)
->orWhere('subscribers.global');
})
->whereNotNull('subscribers.verified_at');
}
|
[
"public",
"function",
"scopeIsVerifiedForComponent",
"(",
"Builder",
"$",
"query",
",",
"$",
"component_id",
")",
"{",
"return",
"$",
"query",
"->",
"select",
"(",
"'subscriptions.*'",
")",
"->",
"join",
"(",
"'subscribers'",
",",
"'subscriptions.subscriber_id'",
",",
"'='",
",",
"'subscribers.id'",
")",
"->",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'subscriptions.component_id'",
",",
"'='",
",",
"$",
"component_id",
")",
"->",
"orWhere",
"(",
"'subscribers.global'",
")",
";",
"}",
")",
"->",
"whereNotNull",
"(",
"'subscribers.verified_at'",
")",
";",
"}"
] |
Finds all verified subscriptions for a component.
@param \Illuminate\Database\Eloquent\Builder $query
@param int $component_id
@return \Illuminate\Database\Eloquent\Builder
|
[
"Finds",
"all",
"verified",
"subscriptions",
"for",
"a",
"component",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Models/Subscription.php#L106-L115
|
220,777
|
CachetHQ/Cachet
|
app/Foundation/Providers/RouteServiceProvider.php
|
RouteServiceProvider.bind
|
public function bind(Router $router)
{
$router->model('component', 'CachetHQ\Cachet\Models\Component');
$router->model('component_group', 'CachetHQ\Cachet\Models\ComponentGroup');
$router->model('incident', 'CachetHQ\Cachet\Models\Incident');
$router->model('incident_template', 'CachetHQ\Cachet\Models\IncidentTemplate');
$router->model('incident_update', 'CachetHQ\Cachet\Models\IncidentUpdate');
$router->model('metric', 'CachetHQ\Cachet\Models\Metric');
$router->model('metric_point', 'CachetHQ\Cachet\Models\MetricPoint');
$router->model('schedule', 'CachetHQ\Cachet\Models\Schedule');
$router->model('setting', 'CachetHQ\Cachet\Models\Setting');
$router->model('subscriber', 'CachetHQ\Cachet\Models\Subscriber');
$router->model('subscription', 'CachetHQ\Cachet\Models\Subscription');
$router->model('tag', 'CachetHQ\Cachet\Models\Tag');
$router->model('user', 'CachetHQ\Cachet\Models\User');
}
|
php
|
public function bind(Router $router)
{
$router->model('component', 'CachetHQ\Cachet\Models\Component');
$router->model('component_group', 'CachetHQ\Cachet\Models\ComponentGroup');
$router->model('incident', 'CachetHQ\Cachet\Models\Incident');
$router->model('incident_template', 'CachetHQ\Cachet\Models\IncidentTemplate');
$router->model('incident_update', 'CachetHQ\Cachet\Models\IncidentUpdate');
$router->model('metric', 'CachetHQ\Cachet\Models\Metric');
$router->model('metric_point', 'CachetHQ\Cachet\Models\MetricPoint');
$router->model('schedule', 'CachetHQ\Cachet\Models\Schedule');
$router->model('setting', 'CachetHQ\Cachet\Models\Setting');
$router->model('subscriber', 'CachetHQ\Cachet\Models\Subscriber');
$router->model('subscription', 'CachetHQ\Cachet\Models\Subscription');
$router->model('tag', 'CachetHQ\Cachet\Models\Tag');
$router->model('user', 'CachetHQ\Cachet\Models\User');
}
|
[
"public",
"function",
"bind",
"(",
"Router",
"$",
"router",
")",
"{",
"$",
"router",
"->",
"model",
"(",
"'component'",
",",
"'CachetHQ\\Cachet\\Models\\Component'",
")",
";",
"$",
"router",
"->",
"model",
"(",
"'component_group'",
",",
"'CachetHQ\\Cachet\\Models\\ComponentGroup'",
")",
";",
"$",
"router",
"->",
"model",
"(",
"'incident'",
",",
"'CachetHQ\\Cachet\\Models\\Incident'",
")",
";",
"$",
"router",
"->",
"model",
"(",
"'incident_template'",
",",
"'CachetHQ\\Cachet\\Models\\IncidentTemplate'",
")",
";",
"$",
"router",
"->",
"model",
"(",
"'incident_update'",
",",
"'CachetHQ\\Cachet\\Models\\IncidentUpdate'",
")",
";",
"$",
"router",
"->",
"model",
"(",
"'metric'",
",",
"'CachetHQ\\Cachet\\Models\\Metric'",
")",
";",
"$",
"router",
"->",
"model",
"(",
"'metric_point'",
",",
"'CachetHQ\\Cachet\\Models\\MetricPoint'",
")",
";",
"$",
"router",
"->",
"model",
"(",
"'schedule'",
",",
"'CachetHQ\\Cachet\\Models\\Schedule'",
")",
";",
"$",
"router",
"->",
"model",
"(",
"'setting'",
",",
"'CachetHQ\\Cachet\\Models\\Setting'",
")",
";",
"$",
"router",
"->",
"model",
"(",
"'subscriber'",
",",
"'CachetHQ\\Cachet\\Models\\Subscriber'",
")",
";",
"$",
"router",
"->",
"model",
"(",
"'subscription'",
",",
"'CachetHQ\\Cachet\\Models\\Subscription'",
")",
";",
"$",
"router",
"->",
"model",
"(",
"'tag'",
",",
"'CachetHQ\\Cachet\\Models\\Tag'",
")",
";",
"$",
"router",
"->",
"model",
"(",
"'user'",
",",
"'CachetHQ\\Cachet\\Models\\User'",
")",
";",
"}"
] |
Define the bindings for the application.
@param \Illuminate\Routing\Router $router
@return void
|
[
"Define",
"the",
"bindings",
"for",
"the",
"application",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Foundation/Providers/RouteServiceProvider.php#L83-L98
|
220,778
|
CachetHQ/Cachet
|
app/Foundation/Providers/RouteServiceProvider.php
|
RouteServiceProvider.mapForBrowser
|
protected function mapForBrowser(Router $router, $routes, $applyAlwaysAuthenticate)
{
$middleware = [
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
];
if ($applyAlwaysAuthenticate && !$this->isWhiteListedAuthRoute($routes)) {
$middleware[] = Authenticate::class;
}
$router->group(['middleware' => $middleware], function (Router $router) use ($routes) {
$routes->map($router);
});
}
|
php
|
protected function mapForBrowser(Router $router, $routes, $applyAlwaysAuthenticate)
{
$middleware = [
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
];
if ($applyAlwaysAuthenticate && !$this->isWhiteListedAuthRoute($routes)) {
$middleware[] = Authenticate::class;
}
$router->group(['middleware' => $middleware], function (Router $router) use ($routes) {
$routes->map($router);
});
}
|
[
"protected",
"function",
"mapForBrowser",
"(",
"Router",
"$",
"router",
",",
"$",
"routes",
",",
"$",
"applyAlwaysAuthenticate",
")",
"{",
"$",
"middleware",
"=",
"[",
"EncryptCookies",
"::",
"class",
",",
"AddQueuedCookiesToResponse",
"::",
"class",
",",
"StartSession",
"::",
"class",
",",
"ShareErrorsFromSession",
"::",
"class",
",",
"VerifyCsrfToken",
"::",
"class",
",",
"SubstituteBindings",
"::",
"class",
",",
"]",
";",
"if",
"(",
"$",
"applyAlwaysAuthenticate",
"&&",
"!",
"$",
"this",
"->",
"isWhiteListedAuthRoute",
"(",
"$",
"routes",
")",
")",
"{",
"$",
"middleware",
"[",
"]",
"=",
"Authenticate",
"::",
"class",
";",
"}",
"$",
"router",
"->",
"group",
"(",
"[",
"'middleware'",
"=>",
"$",
"middleware",
"]",
",",
"function",
"(",
"Router",
"$",
"router",
")",
"use",
"(",
"$",
"routes",
")",
"{",
"$",
"routes",
"->",
"map",
"(",
"$",
"router",
")",
";",
"}",
")",
";",
"}"
] |
Wrap the routes in the browser specific middleware.
@param \Illuminate\Routing\Router $router
@param object $routes
@param bool $applyAlwaysAuthenticate
@return void
|
[
"Wrap",
"the",
"routes",
"in",
"the",
"browser",
"specific",
"middleware",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Foundation/Providers/RouteServiceProvider.php#L141-L159
|
220,779
|
CachetHQ/Cachet
|
app/Foundation/Providers/RouteServiceProvider.php
|
RouteServiceProvider.mapOtherwise
|
protected function mapOtherwise(Router $router, $routes, $applyAlwaysAuthenticate)
{
$middleware = [
SubstituteBindings::class,
Acceptable::class,
Timezone::class,
];
if ($applyAlwaysAuthenticate && !$this->isWhiteListedAuthRoute($routes)) {
$middleware[] = 'auth.api:true';
}
$router->group(['middleware' => $middleware], function (Router $router) use ($routes) {
$routes->map($router);
});
}
|
php
|
protected function mapOtherwise(Router $router, $routes, $applyAlwaysAuthenticate)
{
$middleware = [
SubstituteBindings::class,
Acceptable::class,
Timezone::class,
];
if ($applyAlwaysAuthenticate && !$this->isWhiteListedAuthRoute($routes)) {
$middleware[] = 'auth.api:true';
}
$router->group(['middleware' => $middleware], function (Router $router) use ($routes) {
$routes->map($router);
});
}
|
[
"protected",
"function",
"mapOtherwise",
"(",
"Router",
"$",
"router",
",",
"$",
"routes",
",",
"$",
"applyAlwaysAuthenticate",
")",
"{",
"$",
"middleware",
"=",
"[",
"SubstituteBindings",
"::",
"class",
",",
"Acceptable",
"::",
"class",
",",
"Timezone",
"::",
"class",
",",
"]",
";",
"if",
"(",
"$",
"applyAlwaysAuthenticate",
"&&",
"!",
"$",
"this",
"->",
"isWhiteListedAuthRoute",
"(",
"$",
"routes",
")",
")",
"{",
"$",
"middleware",
"[",
"]",
"=",
"'auth.api:true'",
";",
"}",
"$",
"router",
"->",
"group",
"(",
"[",
"'middleware'",
"=>",
"$",
"middleware",
"]",
",",
"function",
"(",
"Router",
"$",
"router",
")",
"use",
"(",
"$",
"routes",
")",
"{",
"$",
"routes",
"->",
"map",
"(",
"$",
"router",
")",
";",
"}",
")",
";",
"}"
] |
Wrap the routes in the basic middleware.
@param \Illuminate\Routing\Router $router
@param object $routes
@param bool $applyAlwaysAuthenticate
@return void
|
[
"Wrap",
"the",
"routes",
"in",
"the",
"basic",
"middleware",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Foundation/Providers/RouteServiceProvider.php#L170-L185
|
220,780
|
CachetHQ/Cachet
|
app/Foundation/Providers/RouteServiceProvider.php
|
RouteServiceProvider.isWhiteListedAuthRoute
|
private function isWhiteListedAuthRoute($routes)
{
foreach ($this->whitelistedAuthRoutes as $whitelistedRoute) {
if (is_a($routes, $whitelistedRoute)) {
return true;
}
}
return false;
}
|
php
|
private function isWhiteListedAuthRoute($routes)
{
foreach ($this->whitelistedAuthRoutes as $whitelistedRoute) {
if (is_a($routes, $whitelistedRoute)) {
return true;
}
}
return false;
}
|
[
"private",
"function",
"isWhiteListedAuthRoute",
"(",
"$",
"routes",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"whitelistedAuthRoutes",
"as",
"$",
"whitelistedRoute",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"routes",
",",
"$",
"whitelistedRoute",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Validates if the route object is an instance of the whitelisted routes.
A small workaround since we cant use multiple classes in a `instanceof` comparison.
@param object $routes
@return bool
|
[
"Validates",
"if",
"the",
"route",
"object",
"is",
"an",
"instance",
"of",
"the",
"whitelisted",
"routes",
".",
"A",
"small",
"workaround",
"since",
"we",
"cant",
"use",
"multiple",
"classes",
"in",
"a",
"instanceof",
"comparison",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Foundation/Providers/RouteServiceProvider.php#L195-L204
|
220,781
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Invite/ClaimInviteCommandHandler.php
|
ClaimInviteCommandHandler.handle
|
public function handle(ClaimInviteCommand $command)
{
$invite = $command->invite;
$invite->update(['claimed_at' => Carbon::now()]);
event(new InviteWasClaimedEvent($invite));
}
|
php
|
public function handle(ClaimInviteCommand $command)
{
$invite = $command->invite;
$invite->update(['claimed_at' => Carbon::now()]);
event(new InviteWasClaimedEvent($invite));
}
|
[
"public",
"function",
"handle",
"(",
"ClaimInviteCommand",
"$",
"command",
")",
"{",
"$",
"invite",
"=",
"$",
"command",
"->",
"invite",
";",
"$",
"invite",
"->",
"update",
"(",
"[",
"'claimed_at'",
"=>",
"Carbon",
"::",
"now",
"(",
")",
"]",
")",
";",
"event",
"(",
"new",
"InviteWasClaimedEvent",
"(",
"$",
"invite",
")",
")",
";",
"}"
] |
Handle the claim invite command.
@param \CachetHQ\Cachet\Bus\Commands\Invite\ClaimInviteCommand $command
@return void
|
[
"Handle",
"the",
"claim",
"invite",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Invite/ClaimInviteCommandHandler.php#L27-L34
|
220,782
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Incident/RemoveIncidentCommandHandler.php
|
RemoveIncidentCommandHandler.handle
|
public function handle(RemoveIncidentCommand $command)
{
$incident = $command->incident;
event(new IncidentWasRemovedEvent($this->auth->user(), $incident));
$incident->delete();
}
|
php
|
public function handle(RemoveIncidentCommand $command)
{
$incident = $command->incident;
event(new IncidentWasRemovedEvent($this->auth->user(), $incident));
$incident->delete();
}
|
[
"public",
"function",
"handle",
"(",
"RemoveIncidentCommand",
"$",
"command",
")",
"{",
"$",
"incident",
"=",
"$",
"command",
"->",
"incident",
";",
"event",
"(",
"new",
"IncidentWasRemovedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"incident",
")",
")",
";",
"$",
"incident",
"->",
"delete",
"(",
")",
";",
"}"
] |
Handle the remove incident command.
@param \CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand $command
@return void
|
[
"Handle",
"the",
"remove",
"incident",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Incident/RemoveIncidentCommandHandler.php#L46-L53
|
220,783
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/IncidentUpdate/RemoveIncidentUpdateCommandHandler.php
|
RemoveIncidentUpdateCommandHandler.handle
|
public function handle(RemoveIncidentUpdateCommand $command)
{
$update = $command->incidentUpdate;
event(new IncidentUpdateWasRemovedEvent($this->auth->user(), $update));
$update->delete();
}
|
php
|
public function handle(RemoveIncidentUpdateCommand $command)
{
$update = $command->incidentUpdate;
event(new IncidentUpdateWasRemovedEvent($this->auth->user(), $update));
$update->delete();
}
|
[
"public",
"function",
"handle",
"(",
"RemoveIncidentUpdateCommand",
"$",
"command",
")",
"{",
"$",
"update",
"=",
"$",
"command",
"->",
"incidentUpdate",
";",
"event",
"(",
"new",
"IncidentUpdateWasRemovedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"update",
")",
")",
";",
"$",
"update",
"->",
"delete",
"(",
")",
";",
"}"
] |
Handle the remove incident update command.
@param \CachetHQ\Cachet\Bus\Commands\IncidentUpdate\RemoveIncidentUpdateCommand $command
@return void
|
[
"Handle",
"the",
"remove",
"incident",
"update",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/IncidentUpdate/RemoveIncidentUpdateCommandHandler.php#L51-L58
|
220,784
|
CachetHQ/Cachet
|
app/Bus/Handlers/Events/ActionStorageHandler.php
|
ActionStorageHandler.handle
|
public function handle(ActionInterface $event)
{
$data = $event->getAction();
$action = [
'class_name' => get_class($event),
'user_id' => $data['user']->id,
'username' => $data['user']->username,
'description' => $data['description'],
];
if (isset($data['information'])) {
$action['information'] = $data['information'];
}
Action::create($action);
}
|
php
|
public function handle(ActionInterface $event)
{
$data = $event->getAction();
$action = [
'class_name' => get_class($event),
'user_id' => $data['user']->id,
'username' => $data['user']->username,
'description' => $data['description'],
];
if (isset($data['information'])) {
$action['information'] = $data['information'];
}
Action::create($action);
}
|
[
"public",
"function",
"handle",
"(",
"ActionInterface",
"$",
"event",
")",
"{",
"$",
"data",
"=",
"$",
"event",
"->",
"getAction",
"(",
")",
";",
"$",
"action",
"=",
"[",
"'class_name'",
"=>",
"get_class",
"(",
"$",
"event",
")",
",",
"'user_id'",
"=>",
"$",
"data",
"[",
"'user'",
"]",
"->",
"id",
",",
"'username'",
"=>",
"$",
"data",
"[",
"'user'",
"]",
"->",
"username",
",",
"'description'",
"=>",
"$",
"data",
"[",
"'description'",
"]",
",",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'information'",
"]",
")",
")",
"{",
"$",
"action",
"[",
"'information'",
"]",
"=",
"$",
"data",
"[",
"'information'",
"]",
";",
"}",
"Action",
"::",
"create",
"(",
"$",
"action",
")",
";",
"}"
] |
Handle the any actions that need storing.
@param \CachetHQ\Cachet\Bus\Events\ActionInterface $event
@return void
|
[
"Handle",
"the",
"any",
"actions",
"that",
"need",
"storing",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Events/ActionStorageHandler.php#L32-L48
|
220,785
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/User/RemoveUserCommandHandler.php
|
RemoveUserCommandHandler.handle
|
public function handle(RemoveUserCommand $command)
{
$user = $command->user;
event(new UserWasRemovedEvent($user));
$user->delete();
}
|
php
|
public function handle(RemoveUserCommand $command)
{
$user = $command->user;
event(new UserWasRemovedEvent($user));
$user->delete();
}
|
[
"public",
"function",
"handle",
"(",
"RemoveUserCommand",
"$",
"command",
")",
"{",
"$",
"user",
"=",
"$",
"command",
"->",
"user",
";",
"event",
"(",
"new",
"UserWasRemovedEvent",
"(",
"$",
"user",
")",
")",
";",
"$",
"user",
"->",
"delete",
"(",
")",
";",
"}"
] |
Handle the remove user command.
@param \CachetHQ\Cachet\Bus\Commands\User\RemoveUserCommand $command
@return void
|
[
"Handle",
"the",
"remove",
"user",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/User/RemoveUserCommandHandler.php#L27-L34
|
220,786
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/IncidentUpdate/CreateIncidentUpdateCommandHandler.php
|
CreateIncidentUpdateCommandHandler.handle
|
public function handle(CreateIncidentUpdateCommand $command)
{
$data = [
'incident_id' => $command->incident->id,
'status' => $command->status,
'message' => $command->message,
'user_id' => $command->user->id,
];
// Create the incident update.
$update = IncidentUpdate::create($data);
// Update the original incident with the new status.
execute(new UpdateIncidentCommand(
$command->incident,
null,
$command->status,
null,
null,
null,
null,
null,
null,
null,
null,
[]
));
event(new IncidentUpdateWasReportedEvent($this->auth->user(), $update));
return $update;
}
|
php
|
public function handle(CreateIncidentUpdateCommand $command)
{
$data = [
'incident_id' => $command->incident->id,
'status' => $command->status,
'message' => $command->message,
'user_id' => $command->user->id,
];
// Create the incident update.
$update = IncidentUpdate::create($data);
// Update the original incident with the new status.
execute(new UpdateIncidentCommand(
$command->incident,
null,
$command->status,
null,
null,
null,
null,
null,
null,
null,
null,
[]
));
event(new IncidentUpdateWasReportedEvent($this->auth->user(), $update));
return $update;
}
|
[
"public",
"function",
"handle",
"(",
"CreateIncidentUpdateCommand",
"$",
"command",
")",
"{",
"$",
"data",
"=",
"[",
"'incident_id'",
"=>",
"$",
"command",
"->",
"incident",
"->",
"id",
",",
"'status'",
"=>",
"$",
"command",
"->",
"status",
",",
"'message'",
"=>",
"$",
"command",
"->",
"message",
",",
"'user_id'",
"=>",
"$",
"command",
"->",
"user",
"->",
"id",
",",
"]",
";",
"// Create the incident update.",
"$",
"update",
"=",
"IncidentUpdate",
"::",
"create",
"(",
"$",
"data",
")",
";",
"// Update the original incident with the new status.",
"execute",
"(",
"new",
"UpdateIncidentCommand",
"(",
"$",
"command",
"->",
"incident",
",",
"null",
",",
"$",
"command",
"->",
"status",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"[",
"]",
")",
")",
";",
"event",
"(",
"new",
"IncidentUpdateWasReportedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"update",
")",
")",
";",
"return",
"$",
"update",
";",
"}"
] |
Handle the report incident command.
@param \CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand $command
@return \CachetHQ\Cachet\Models\IncidentUpdate
|
[
"Handle",
"the",
"report",
"incident",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/IncidentUpdate/CreateIncidentUpdateCommandHandler.php#L53-L84
|
220,787
|
CachetHQ/Cachet
|
app/Http/Controllers/Dashboard/SubscriberController.php
|
SubscriberController.createSubscriberAction
|
public function createSubscriberAction()
{
$verified = app(Repository::class)->get('setting.skip_subscriber_verification');
try {
$subscribers = preg_split("/\r\n|\n|\r/", Binput::get('email'));
foreach ($subscribers as $subscriber) {
execute(new SubscribeSubscriberCommand($subscriber, $verified));
}
} catch (ValidationException $e) {
return cachet_redirect('dashboard.subscribers.create')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))
->withErrors($e->getMessageBag());
}
return cachet_redirect('dashboard.subscribers.create')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')));
}
|
php
|
public function createSubscriberAction()
{
$verified = app(Repository::class)->get('setting.skip_subscriber_verification');
try {
$subscribers = preg_split("/\r\n|\n|\r/", Binput::get('email'));
foreach ($subscribers as $subscriber) {
execute(new SubscribeSubscriberCommand($subscriber, $verified));
}
} catch (ValidationException $e) {
return cachet_redirect('dashboard.subscribers.create')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))
->withErrors($e->getMessageBag());
}
return cachet_redirect('dashboard.subscribers.create')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')));
}
|
[
"public",
"function",
"createSubscriberAction",
"(",
")",
"{",
"$",
"verified",
"=",
"app",
"(",
"Repository",
"::",
"class",
")",
"->",
"get",
"(",
"'setting.skip_subscriber_verification'",
")",
";",
"try",
"{",
"$",
"subscribers",
"=",
"preg_split",
"(",
"\"/\\r\\n|\\n|\\r/\"",
",",
"Binput",
"::",
"get",
"(",
"'email'",
")",
")",
";",
"foreach",
"(",
"$",
"subscribers",
"as",
"$",
"subscriber",
")",
"{",
"execute",
"(",
"new",
"SubscribeSubscriberCommand",
"(",
"$",
"subscriber",
",",
"$",
"verified",
")",
")",
";",
"}",
"}",
"catch",
"(",
"ValidationException",
"$",
"e",
")",
"{",
"return",
"cachet_redirect",
"(",
"'dashboard.subscribers.create'",
")",
"->",
"withInput",
"(",
"Binput",
"::",
"all",
"(",
")",
")",
"->",
"withTitle",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.whoops'",
")",
",",
"trans",
"(",
"'dashboard.subscribers.add.failure'",
")",
")",
")",
"->",
"withErrors",
"(",
"$",
"e",
"->",
"getMessageBag",
"(",
")",
")",
";",
"}",
"return",
"cachet_redirect",
"(",
"'dashboard.subscribers.create'",
")",
"->",
"withSuccess",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.awesome'",
")",
",",
"trans",
"(",
"'dashboard.subscribers.add.success'",
")",
")",
")",
";",
"}"
] |
Creates a new subscriber.
@return \Illuminate\Http\RedirectResponse
|
[
"Creates",
"a",
"new",
"subscriber",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/SubscriberController.php#L53-L72
|
220,788
|
CachetHQ/Cachet
|
app/Http/Routes/ApiRoutes.php
|
ApiRoutes.map
|
public function map(Registrar $router)
{
$router->group([
'namespace' => 'Api',
'prefix' => 'api/v1',
], function (Registrar $router) {
$router->group(['middleware' => ['auth.api', 'cors']], function (Registrar $router) {
$router->get('components', 'ComponentController@index');
$router->get('components/groups', 'ComponentGroupController@index');
$router->get('components/groups/{component_group}', 'ComponentGroupController@show');
$router->get('components/{component}', 'ComponentController@show');
$router->get('incidents', 'IncidentController@index');
$router->get('incidents/templates', 'IncidentTemplateController@index');
$router->get('incidents/templates/{incident_template}', 'IncidentTemplateController@show');
$router->get('incidents/{incident}', 'IncidentController@show');
$router->get('incidents/{incident}/updates', 'IncidentUpdateController@index');
$router->get('incidents/{incident}/updates/{update}', 'IncidentUpdateController@show');
$router->get('metrics', 'MetricController@index');
$router->get('metrics/{metric}', 'MetricController@show');
$router->get('metrics/{metric}/points', 'MetricPointController@index');
$router->get('schedules', 'ScheduleController@index');
$router->get('schedules/{schedule}', 'ScheduleController@show');
});
$router->group(['middleware' => ['auth.api:true']], function (Registrar $router) {
$router->get('subscribers', 'SubscriberController@index');
$router->post('components', 'ComponentController@store');
$router->post('components/groups', 'ComponentGroupController@store');
$router->post('incidents', 'IncidentController@store');
$router->post('incidents/{incident}/updates', 'IncidentUpdateController@store');
$router->post('metrics', 'MetricController@store');
$router->post('metrics/{metric}/points', 'MetricPointController@store');
$router->post('schedules', 'ScheduleController@store');
$router->post('subscribers', 'SubscriberController@store');
$router->put('components/groups/{component_group}', 'ComponentGroupController@update');
$router->put('components/{component}', 'ComponentController@update');
$router->put('incidents/{incident}', 'IncidentController@update');
$router->put('incidents/{incident}/updates/{update}', 'IncidentUpdateController@update');
$router->put('metrics/{metric}', 'MetricController@update');
$router->put('metrics/{metric}/points/{metric_point}', 'MetricPointController@update');
$router->put('schedules/{schedule}', 'ScheduleController@update');
$router->delete('components/groups/{component_group}', 'ComponentGroupController@destroy');
$router->delete('components/{component}', 'ComponentController@destroy');
$router->delete('incidents/{incident}', 'IncidentController@destroy');
$router->delete('incidents/{incident}/updates/{update}', 'IncidentUpdateController@destroy');
$router->delete('metrics/{metric}', 'MetricController@destroy');
$router->delete('metrics/{metric}/points/{metric_point}', 'MetricPointController@destroy');
$router->delete('schedules/{schedule}', 'ScheduleController@destroy');
$router->delete('subscribers/{subscriber}', 'SubscriberController@destroy');
$router->delete('subscriptions/{subscription}', 'SubscriptionController@destroy');
});
});
}
|
php
|
public function map(Registrar $router)
{
$router->group([
'namespace' => 'Api',
'prefix' => 'api/v1',
], function (Registrar $router) {
$router->group(['middleware' => ['auth.api', 'cors']], function (Registrar $router) {
$router->get('components', 'ComponentController@index');
$router->get('components/groups', 'ComponentGroupController@index');
$router->get('components/groups/{component_group}', 'ComponentGroupController@show');
$router->get('components/{component}', 'ComponentController@show');
$router->get('incidents', 'IncidentController@index');
$router->get('incidents/templates', 'IncidentTemplateController@index');
$router->get('incidents/templates/{incident_template}', 'IncidentTemplateController@show');
$router->get('incidents/{incident}', 'IncidentController@show');
$router->get('incidents/{incident}/updates', 'IncidentUpdateController@index');
$router->get('incidents/{incident}/updates/{update}', 'IncidentUpdateController@show');
$router->get('metrics', 'MetricController@index');
$router->get('metrics/{metric}', 'MetricController@show');
$router->get('metrics/{metric}/points', 'MetricPointController@index');
$router->get('schedules', 'ScheduleController@index');
$router->get('schedules/{schedule}', 'ScheduleController@show');
});
$router->group(['middleware' => ['auth.api:true']], function (Registrar $router) {
$router->get('subscribers', 'SubscriberController@index');
$router->post('components', 'ComponentController@store');
$router->post('components/groups', 'ComponentGroupController@store');
$router->post('incidents', 'IncidentController@store');
$router->post('incidents/{incident}/updates', 'IncidentUpdateController@store');
$router->post('metrics', 'MetricController@store');
$router->post('metrics/{metric}/points', 'MetricPointController@store');
$router->post('schedules', 'ScheduleController@store');
$router->post('subscribers', 'SubscriberController@store');
$router->put('components/groups/{component_group}', 'ComponentGroupController@update');
$router->put('components/{component}', 'ComponentController@update');
$router->put('incidents/{incident}', 'IncidentController@update');
$router->put('incidents/{incident}/updates/{update}', 'IncidentUpdateController@update');
$router->put('metrics/{metric}', 'MetricController@update');
$router->put('metrics/{metric}/points/{metric_point}', 'MetricPointController@update');
$router->put('schedules/{schedule}', 'ScheduleController@update');
$router->delete('components/groups/{component_group}', 'ComponentGroupController@destroy');
$router->delete('components/{component}', 'ComponentController@destroy');
$router->delete('incidents/{incident}', 'IncidentController@destroy');
$router->delete('incidents/{incident}/updates/{update}', 'IncidentUpdateController@destroy');
$router->delete('metrics/{metric}', 'MetricController@destroy');
$router->delete('metrics/{metric}/points/{metric_point}', 'MetricPointController@destroy');
$router->delete('schedules/{schedule}', 'ScheduleController@destroy');
$router->delete('subscribers/{subscriber}', 'SubscriberController@destroy');
$router->delete('subscriptions/{subscription}', 'SubscriptionController@destroy');
});
});
}
|
[
"public",
"function",
"map",
"(",
"Registrar",
"$",
"router",
")",
"{",
"$",
"router",
"->",
"group",
"(",
"[",
"'namespace'",
"=>",
"'Api'",
",",
"'prefix'",
"=>",
"'api/v1'",
",",
"]",
",",
"function",
"(",
"Registrar",
"$",
"router",
")",
"{",
"$",
"router",
"->",
"group",
"(",
"[",
"'middleware'",
"=>",
"[",
"'auth.api'",
",",
"'cors'",
"]",
"]",
",",
"function",
"(",
"Registrar",
"$",
"router",
")",
"{",
"$",
"router",
"->",
"get",
"(",
"'components'",
",",
"'ComponentController@index'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'components/groups'",
",",
"'ComponentGroupController@index'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'components/groups/{component_group}'",
",",
"'ComponentGroupController@show'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'components/{component}'",
",",
"'ComponentController@show'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'incidents'",
",",
"'IncidentController@index'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'incidents/templates'",
",",
"'IncidentTemplateController@index'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'incidents/templates/{incident_template}'",
",",
"'IncidentTemplateController@show'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'incidents/{incident}'",
",",
"'IncidentController@show'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'incidents/{incident}/updates'",
",",
"'IncidentUpdateController@index'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'incidents/{incident}/updates/{update}'",
",",
"'IncidentUpdateController@show'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'metrics'",
",",
"'MetricController@index'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'metrics/{metric}'",
",",
"'MetricController@show'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'metrics/{metric}/points'",
",",
"'MetricPointController@index'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'schedules'",
",",
"'ScheduleController@index'",
")",
";",
"$",
"router",
"->",
"get",
"(",
"'schedules/{schedule}'",
",",
"'ScheduleController@show'",
")",
";",
"}",
")",
";",
"$",
"router",
"->",
"group",
"(",
"[",
"'middleware'",
"=>",
"[",
"'auth.api:true'",
"]",
"]",
",",
"function",
"(",
"Registrar",
"$",
"router",
")",
"{",
"$",
"router",
"->",
"get",
"(",
"'subscribers'",
",",
"'SubscriberController@index'",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'components'",
",",
"'ComponentController@store'",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'components/groups'",
",",
"'ComponentGroupController@store'",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'incidents'",
",",
"'IncidentController@store'",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'incidents/{incident}/updates'",
",",
"'IncidentUpdateController@store'",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'metrics'",
",",
"'MetricController@store'",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'metrics/{metric}/points'",
",",
"'MetricPointController@store'",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'schedules'",
",",
"'ScheduleController@store'",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'subscribers'",
",",
"'SubscriberController@store'",
")",
";",
"$",
"router",
"->",
"put",
"(",
"'components/groups/{component_group}'",
",",
"'ComponentGroupController@update'",
")",
";",
"$",
"router",
"->",
"put",
"(",
"'components/{component}'",
",",
"'ComponentController@update'",
")",
";",
"$",
"router",
"->",
"put",
"(",
"'incidents/{incident}'",
",",
"'IncidentController@update'",
")",
";",
"$",
"router",
"->",
"put",
"(",
"'incidents/{incident}/updates/{update}'",
",",
"'IncidentUpdateController@update'",
")",
";",
"$",
"router",
"->",
"put",
"(",
"'metrics/{metric}'",
",",
"'MetricController@update'",
")",
";",
"$",
"router",
"->",
"put",
"(",
"'metrics/{metric}/points/{metric_point}'",
",",
"'MetricPointController@update'",
")",
";",
"$",
"router",
"->",
"put",
"(",
"'schedules/{schedule}'",
",",
"'ScheduleController@update'",
")",
";",
"$",
"router",
"->",
"delete",
"(",
"'components/groups/{component_group}'",
",",
"'ComponentGroupController@destroy'",
")",
";",
"$",
"router",
"->",
"delete",
"(",
"'components/{component}'",
",",
"'ComponentController@destroy'",
")",
";",
"$",
"router",
"->",
"delete",
"(",
"'incidents/{incident}'",
",",
"'IncidentController@destroy'",
")",
";",
"$",
"router",
"->",
"delete",
"(",
"'incidents/{incident}/updates/{update}'",
",",
"'IncidentUpdateController@destroy'",
")",
";",
"$",
"router",
"->",
"delete",
"(",
"'metrics/{metric}'",
",",
"'MetricController@destroy'",
")",
";",
"$",
"router",
"->",
"delete",
"(",
"'metrics/{metric}/points/{metric_point}'",
",",
"'MetricPointController@destroy'",
")",
";",
"$",
"router",
"->",
"delete",
"(",
"'schedules/{schedule}'",
",",
"'ScheduleController@destroy'",
")",
";",
"$",
"router",
"->",
"delete",
"(",
"'subscribers/{subscriber}'",
",",
"'SubscriberController@destroy'",
")",
";",
"$",
"router",
"->",
"delete",
"(",
"'subscriptions/{subscription}'",
",",
"'SubscriptionController@destroy'",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Define the api routes.
@param \Illuminate\Contracts\Routing\Registrar $router
@return void
|
[
"Define",
"the",
"api",
"routes",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Routes/ApiRoutes.php#L37-L97
|
220,789
|
CachetHQ/Cachet
|
app/Settings/Cache.php
|
Cache.store
|
public function store($env, array $data)
{
$this->files->put($this->path($env), '<?php return '.var_export($data, true).';'.PHP_EOL);
}
|
php
|
public function store($env, array $data)
{
$this->files->put($this->path($env), '<?php return '.var_export($data, true).';'.PHP_EOL);
}
|
[
"public",
"function",
"store",
"(",
"$",
"env",
",",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"$",
"this",
"->",
"path",
"(",
"$",
"env",
")",
",",
"'<?php return '",
".",
"var_export",
"(",
"$",
"data",
",",
"true",
")",
".",
"';'",
".",
"PHP_EOL",
")",
";",
"}"
] |
Store the settings in the cache.
@param string $env
@param array $data
@return void
|
[
"Store",
"the",
"settings",
"in",
"the",
"cache",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Settings/Cache.php#L61-L64
|
220,790
|
CachetHQ/Cachet
|
app/Settings/Cache.php
|
Cache.load
|
public function load($env)
{
try {
return $this->files->getRequire($this->path($env));
} catch (Exception $e) {
return false;
}
}
|
php
|
public function load($env)
{
try {
return $this->files->getRequire($this->path($env));
} catch (Exception $e) {
return false;
}
}
|
[
"public",
"function",
"load",
"(",
"$",
"env",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"files",
"->",
"getRequire",
"(",
"$",
"this",
"->",
"path",
"(",
"$",
"env",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Load the settings from the cache.
@param string $env
@return array|false
|
[
"Load",
"the",
"settings",
"from",
"the",
"cache",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Settings/Cache.php#L73-L80
|
220,791
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Metric/CreateMetricPointCommandHandler.php
|
CreateMetricPointCommandHandler.handle
|
public function handle(CreateMetricPointCommand $command)
{
$metric = $command->metric;
$createdAt = $command->created_at;
// Do we have an existing point with the same value?
$point = $this->findOrCreatePoint($command);
$point->increment('counter', 1);
event(new MetricPointWasCreatedEvent($this->auth->user(), $point));
return $point;
}
|
php
|
public function handle(CreateMetricPointCommand $command)
{
$metric = $command->metric;
$createdAt = $command->created_at;
// Do we have an existing point with the same value?
$point = $this->findOrCreatePoint($command);
$point->increment('counter', 1);
event(new MetricPointWasCreatedEvent($this->auth->user(), $point));
return $point;
}
|
[
"public",
"function",
"handle",
"(",
"CreateMetricPointCommand",
"$",
"command",
")",
"{",
"$",
"metric",
"=",
"$",
"command",
"->",
"metric",
";",
"$",
"createdAt",
"=",
"$",
"command",
"->",
"created_at",
";",
"// Do we have an existing point with the same value?",
"$",
"point",
"=",
"$",
"this",
"->",
"findOrCreatePoint",
"(",
"$",
"command",
")",
";",
"$",
"point",
"->",
"increment",
"(",
"'counter'",
",",
"1",
")",
";",
"event",
"(",
"new",
"MetricPointWasCreatedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"point",
")",
")",
";",
"return",
"$",
"point",
";",
"}"
] |
Handle the add metric point command.
@param \CachetHQ\Cachet\Bus\Commands\Metric\CreateMetricPointCommand $command
@return \CachetHQ\Cachet\Models\MetricPoint
|
[
"Handle",
"the",
"add",
"metric",
"point",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Metric/CreateMetricPointCommandHandler.php#L58-L71
|
220,792
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Metric/CreateMetricPointCommandHandler.php
|
CreateMetricPointCommandHandler.findOrCreatePoint
|
protected function findOrCreatePoint(CreateMetricPointCommand $command)
{
$buffer = Carbon::now()->subMinutes($command->metric->threshold - 1)->startOfMinute();
if ($point = MetricPoint::where('metric_id', '=', $command->metric->id)->where('value', '=', $command->value)->where('created_at', '>=', $buffer)->first()) {
return $point;
}
$data = [
'metric_id' => $command->metric->id,
'value' => $command->value,
'counter' => 0,
];
if ($command->created_at) {
$data['created_at'] = $this->dates->create('U', $command->created_at)->format('Y-m-d H:i:s');
}
return MetricPoint::create($data);
}
|
php
|
protected function findOrCreatePoint(CreateMetricPointCommand $command)
{
$buffer = Carbon::now()->subMinutes($command->metric->threshold - 1)->startOfMinute();
if ($point = MetricPoint::where('metric_id', '=', $command->metric->id)->where('value', '=', $command->value)->where('created_at', '>=', $buffer)->first()) {
return $point;
}
$data = [
'metric_id' => $command->metric->id,
'value' => $command->value,
'counter' => 0,
];
if ($command->created_at) {
$data['created_at'] = $this->dates->create('U', $command->created_at)->format('Y-m-d H:i:s');
}
return MetricPoint::create($data);
}
|
[
"protected",
"function",
"findOrCreatePoint",
"(",
"CreateMetricPointCommand",
"$",
"command",
")",
"{",
"$",
"buffer",
"=",
"Carbon",
"::",
"now",
"(",
")",
"->",
"subMinutes",
"(",
"$",
"command",
"->",
"metric",
"->",
"threshold",
"-",
"1",
")",
"->",
"startOfMinute",
"(",
")",
";",
"if",
"(",
"$",
"point",
"=",
"MetricPoint",
"::",
"where",
"(",
"'metric_id'",
",",
"'='",
",",
"$",
"command",
"->",
"metric",
"->",
"id",
")",
"->",
"where",
"(",
"'value'",
",",
"'='",
",",
"$",
"command",
"->",
"value",
")",
"->",
"where",
"(",
"'created_at'",
",",
"'>='",
",",
"$",
"buffer",
")",
"->",
"first",
"(",
")",
")",
"{",
"return",
"$",
"point",
";",
"}",
"$",
"data",
"=",
"[",
"'metric_id'",
"=>",
"$",
"command",
"->",
"metric",
"->",
"id",
",",
"'value'",
"=>",
"$",
"command",
"->",
"value",
",",
"'counter'",
"=>",
"0",
",",
"]",
";",
"if",
"(",
"$",
"command",
"->",
"created_at",
")",
"{",
"$",
"data",
"[",
"'created_at'",
"]",
"=",
"$",
"this",
"->",
"dates",
"->",
"create",
"(",
"'U'",
",",
"$",
"command",
"->",
"created_at",
")",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
";",
"}",
"return",
"MetricPoint",
"::",
"create",
"(",
"$",
"data",
")",
";",
"}"
] |
Find or create a metric point.
@param \CachetHQ\Cachet\Bus\Commands\Metric\CreateMetricPointCommand $command
@return \CachetHQ\Cachet\Models\MetricPoint
|
[
"Find",
"or",
"create",
"a",
"metric",
"point",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Metric/CreateMetricPointCommandHandler.php#L80-L99
|
220,793
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Schedule/DeleteScheduleCommandHandler.php
|
DeleteScheduleCommandHandler.handle
|
public function handle(DeleteScheduleCommand $command)
{
$schedule = $command->schedule;
event(new ScheduleWasRemovedEvent($this->auth->user(), $schedule));
$schedule->delete();
}
|
php
|
public function handle(DeleteScheduleCommand $command)
{
$schedule = $command->schedule;
event(new ScheduleWasRemovedEvent($this->auth->user(), $schedule));
$schedule->delete();
}
|
[
"public",
"function",
"handle",
"(",
"DeleteScheduleCommand",
"$",
"command",
")",
"{",
"$",
"schedule",
"=",
"$",
"command",
"->",
"schedule",
";",
"event",
"(",
"new",
"ScheduleWasRemovedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"schedule",
")",
")",
";",
"$",
"schedule",
"->",
"delete",
"(",
")",
";",
"}"
] |
Handle the delete schedule command.
@param \CachetHQ\Cachet\Bus\Commands\Schedule\DeleteScheduleCommand $command
@return void
|
[
"Handle",
"the",
"delete",
"schedule",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Schedule/DeleteScheduleCommandHandler.php#L51-L58
|
220,794
|
CachetHQ/Cachet
|
app/Console/Commands/DemoSeederCommand.php
|
DemoSeederCommand.seedComponentGroups
|
protected function seedComponentGroups()
{
$defaultGroups = [
[
'name' => 'Websites',
'order' => 1,
'collapsed' => 0,
'visible' => ComponentGroup::VISIBLE_AUTHENTICATED,
], [
'name' => 'Alt Three',
'order' => 2,
'collapsed' => 1,
'visible' => ComponentGroup::VISIBLE_GUEST,
],
];
ComponentGroup::truncate();
foreach ($defaultGroups as $group) {
ComponentGroup::create($group);
}
}
|
php
|
protected function seedComponentGroups()
{
$defaultGroups = [
[
'name' => 'Websites',
'order' => 1,
'collapsed' => 0,
'visible' => ComponentGroup::VISIBLE_AUTHENTICATED,
], [
'name' => 'Alt Three',
'order' => 2,
'collapsed' => 1,
'visible' => ComponentGroup::VISIBLE_GUEST,
],
];
ComponentGroup::truncate();
foreach ($defaultGroups as $group) {
ComponentGroup::create($group);
}
}
|
[
"protected",
"function",
"seedComponentGroups",
"(",
")",
"{",
"$",
"defaultGroups",
"=",
"[",
"[",
"'name'",
"=>",
"'Websites'",
",",
"'order'",
"=>",
"1",
",",
"'collapsed'",
"=>",
"0",
",",
"'visible'",
"=>",
"ComponentGroup",
"::",
"VISIBLE_AUTHENTICATED",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Alt Three'",
",",
"'order'",
"=>",
"2",
",",
"'collapsed'",
"=>",
"1",
",",
"'visible'",
"=>",
"ComponentGroup",
"::",
"VISIBLE_GUEST",
",",
"]",
",",
"]",
";",
"ComponentGroup",
"::",
"truncate",
"(",
")",
";",
"foreach",
"(",
"$",
"defaultGroups",
"as",
"$",
"group",
")",
"{",
"ComponentGroup",
"::",
"create",
"(",
"$",
"group",
")",
";",
"}",
"}"
] |
Seed the component groups table.
@return void
|
[
"Seed",
"the",
"component",
"groups",
"table",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/DemoSeederCommand.php#L118-L139
|
220,795
|
CachetHQ/Cachet
|
app/Console/Commands/DemoSeederCommand.php
|
DemoSeederCommand.seedComponents
|
protected function seedComponents()
{
$defaultComponents = [
[
'name' => 'API',
'description' => 'Used by third-parties to connect to us',
'status' => 1,
'order' => 0,
'group_id' => 0,
'link' => '',
], [
'name' => 'Documentation',
'description' => 'Kindly powered by Readme.io',
'status' => 1,
'order' => 0,
'group_id' => 1,
'link' => 'https://docs.cachethq.io',
], [
'name' => 'Website',
'description' => '',
'status' => 1,
'order' => 0,
'group_id' => 1,
'link' => 'https://cachethq.io',
], [
'name' => 'Blog',
'description' => 'The Alt Three Blog.',
'status' => 1,
'order' => 0,
'group_id' => 2,
'link' => 'https://blog.alt-three.com',
], [
'name' => 'StyleCI',
'description' => 'The PHP Coding Style Service.',
'status' => 1,
'order' => 1,
'group_id' => 2,
'link' => 'https://styleci.io',
], [
'name' => 'GitHub',
'description' => '',
'status' => 1,
'order' => 0,
'group_id' => 0,
'link' => 'https://github.com/CachetHQ/Cachet',
],
];
Component::truncate();
foreach ($defaultComponents as $component) {
Component::create($component);
}
}
|
php
|
protected function seedComponents()
{
$defaultComponents = [
[
'name' => 'API',
'description' => 'Used by third-parties to connect to us',
'status' => 1,
'order' => 0,
'group_id' => 0,
'link' => '',
], [
'name' => 'Documentation',
'description' => 'Kindly powered by Readme.io',
'status' => 1,
'order' => 0,
'group_id' => 1,
'link' => 'https://docs.cachethq.io',
], [
'name' => 'Website',
'description' => '',
'status' => 1,
'order' => 0,
'group_id' => 1,
'link' => 'https://cachethq.io',
], [
'name' => 'Blog',
'description' => 'The Alt Three Blog.',
'status' => 1,
'order' => 0,
'group_id' => 2,
'link' => 'https://blog.alt-three.com',
], [
'name' => 'StyleCI',
'description' => 'The PHP Coding Style Service.',
'status' => 1,
'order' => 1,
'group_id' => 2,
'link' => 'https://styleci.io',
], [
'name' => 'GitHub',
'description' => '',
'status' => 1,
'order' => 0,
'group_id' => 0,
'link' => 'https://github.com/CachetHQ/Cachet',
],
];
Component::truncate();
foreach ($defaultComponents as $component) {
Component::create($component);
}
}
|
[
"protected",
"function",
"seedComponents",
"(",
")",
"{",
"$",
"defaultComponents",
"=",
"[",
"[",
"'name'",
"=>",
"'API'",
",",
"'description'",
"=>",
"'Used by third-parties to connect to us'",
",",
"'status'",
"=>",
"1",
",",
"'order'",
"=>",
"0",
",",
"'group_id'",
"=>",
"0",
",",
"'link'",
"=>",
"''",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Documentation'",
",",
"'description'",
"=>",
"'Kindly powered by Readme.io'",
",",
"'status'",
"=>",
"1",
",",
"'order'",
"=>",
"0",
",",
"'group_id'",
"=>",
"1",
",",
"'link'",
"=>",
"'https://docs.cachethq.io'",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Website'",
",",
"'description'",
"=>",
"''",
",",
"'status'",
"=>",
"1",
",",
"'order'",
"=>",
"0",
",",
"'group_id'",
"=>",
"1",
",",
"'link'",
"=>",
"'https://cachethq.io'",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Blog'",
",",
"'description'",
"=>",
"'The Alt Three Blog.'",
",",
"'status'",
"=>",
"1",
",",
"'order'",
"=>",
"0",
",",
"'group_id'",
"=>",
"2",
",",
"'link'",
"=>",
"'https://blog.alt-three.com'",
",",
"]",
",",
"[",
"'name'",
"=>",
"'StyleCI'",
",",
"'description'",
"=>",
"'The PHP Coding Style Service.'",
",",
"'status'",
"=>",
"1",
",",
"'order'",
"=>",
"1",
",",
"'group_id'",
"=>",
"2",
",",
"'link'",
"=>",
"'https://styleci.io'",
",",
"]",
",",
"[",
"'name'",
"=>",
"'GitHub'",
",",
"'description'",
"=>",
"''",
",",
"'status'",
"=>",
"1",
",",
"'order'",
"=>",
"0",
",",
"'group_id'",
"=>",
"0",
",",
"'link'",
"=>",
"'https://github.com/CachetHQ/Cachet'",
",",
"]",
",",
"]",
";",
"Component",
"::",
"truncate",
"(",
")",
";",
"foreach",
"(",
"$",
"defaultComponents",
"as",
"$",
"component",
")",
"{",
"Component",
"::",
"create",
"(",
"$",
"component",
")",
";",
"}",
"}"
] |
Seed the components table.
@return void
|
[
"Seed",
"the",
"components",
"table",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/DemoSeederCommand.php#L146-L199
|
220,796
|
CachetHQ/Cachet
|
app/Console/Commands/DemoSeederCommand.php
|
DemoSeederCommand.seedIncidents
|
protected function seedIncidents()
{
$incidentMessage = <<<'EINCIDENT'
# Of course it does!
What kind of web application doesn't these days?
## Headers are fun aren't they
It's _exactly_ why we need Markdown. For **emphasis** and such.
EINCIDENT;
$defaultIncidents = [
[
'name' => 'Our monkeys aren\'t performing',
'message' => 'We\'re investigating an issue with our monkeys not performing as they should be.',
'status' => Incident::INVESTIGATING,
'component_id' => 0,
'visible' => 1,
'stickied' => false,
'user_id' => 1,
'occurred_at' => Carbon::now(),
],
[
'name' => 'This is an unresolved incident',
'message' => 'Unresolved incidents are left without a **Fixed** update.',
'status' => Incident::INVESTIGATING,
'component_id' => 0,
'visible' => 1,
'stickied' => false,
'user_id' => 1,
'occurred_at' => Carbon::now(),
],
];
Incident::truncate();
IncidentUpdate::truncate();
foreach ($defaultIncidents as $defaultIncident) {
$incident = Incident::create($defaultIncident);
$this->seedIncidentUpdates($incident);
}
}
|
php
|
protected function seedIncidents()
{
$incidentMessage = <<<'EINCIDENT'
# Of course it does!
What kind of web application doesn't these days?
## Headers are fun aren't they
It's _exactly_ why we need Markdown. For **emphasis** and such.
EINCIDENT;
$defaultIncidents = [
[
'name' => 'Our monkeys aren\'t performing',
'message' => 'We\'re investigating an issue with our monkeys not performing as they should be.',
'status' => Incident::INVESTIGATING,
'component_id' => 0,
'visible' => 1,
'stickied' => false,
'user_id' => 1,
'occurred_at' => Carbon::now(),
],
[
'name' => 'This is an unresolved incident',
'message' => 'Unresolved incidents are left without a **Fixed** update.',
'status' => Incident::INVESTIGATING,
'component_id' => 0,
'visible' => 1,
'stickied' => false,
'user_id' => 1,
'occurred_at' => Carbon::now(),
],
];
Incident::truncate();
IncidentUpdate::truncate();
foreach ($defaultIncidents as $defaultIncident) {
$incident = Incident::create($defaultIncident);
$this->seedIncidentUpdates($incident);
}
}
|
[
"protected",
"function",
"seedIncidents",
"(",
")",
"{",
"$",
"incidentMessage",
"=",
" <<<'EINCIDENT'\n# Of course it does!\n\nWhat kind of web application doesn't these days?\n\n## Headers are fun aren't they\n\nIt's _exactly_ why we need Markdown. For **emphasis** and such.\nEINCIDENT",
";",
"$",
"defaultIncidents",
"=",
"[",
"[",
"'name'",
"=>",
"'Our monkeys aren\\'t performing'",
",",
"'message'",
"=>",
"'We\\'re investigating an issue with our monkeys not performing as they should be.'",
",",
"'status'",
"=>",
"Incident",
"::",
"INVESTIGATING",
",",
"'component_id'",
"=>",
"0",
",",
"'visible'",
"=>",
"1",
",",
"'stickied'",
"=>",
"false",
",",
"'user_id'",
"=>",
"1",
",",
"'occurred_at'",
"=>",
"Carbon",
"::",
"now",
"(",
")",
",",
"]",
",",
"[",
"'name'",
"=>",
"'This is an unresolved incident'",
",",
"'message'",
"=>",
"'Unresolved incidents are left without a **Fixed** update.'",
",",
"'status'",
"=>",
"Incident",
"::",
"INVESTIGATING",
",",
"'component_id'",
"=>",
"0",
",",
"'visible'",
"=>",
"1",
",",
"'stickied'",
"=>",
"false",
",",
"'user_id'",
"=>",
"1",
",",
"'occurred_at'",
"=>",
"Carbon",
"::",
"now",
"(",
")",
",",
"]",
",",
"]",
";",
"Incident",
"::",
"truncate",
"(",
")",
";",
"IncidentUpdate",
"::",
"truncate",
"(",
")",
";",
"foreach",
"(",
"$",
"defaultIncidents",
"as",
"$",
"defaultIncident",
")",
"{",
"$",
"incident",
"=",
"Incident",
"::",
"create",
"(",
"$",
"defaultIncident",
")",
";",
"$",
"this",
"->",
"seedIncidentUpdates",
"(",
"$",
"incident",
")",
";",
"}",
"}"
] |
Seed the incidents table.
@return void
|
[
"Seed",
"the",
"incidents",
"table",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/DemoSeederCommand.php#L206-L249
|
220,797
|
CachetHQ/Cachet
|
app/Console/Commands/DemoSeederCommand.php
|
DemoSeederCommand.seedIncidentUpdates
|
protected function seedIncidentUpdates($incident)
{
$defaultUpdates = [
1 => [
[
'status' => Incident::FIXED,
'message' => 'The monkeys are back and rested!',
'user_id' => 1,
], [
'status' => Incident::WATCHED,
'message' => 'Our monkeys need a break from performing. They\'ll be back after a good rest.',
'user_id' => 1,
], [
'status' => Incident::IDENTIFIED,
'message' => 'We have identified the issue with our lovely performing monkeys.',
'user_id' => 1,
],
],
2 => [
[
'status' => Incident::WATCHED,
'message' => 'We\'re actively watching this issue, so it remains unresolved.',
'user_id' => 1,
],
],
];
$updates = $defaultUpdates[$incident->id];
foreach ($updates as $updateId => $update) {
$update['incident_id'] = $incident->id;
IncidentUpdate::create($update);
}
}
|
php
|
protected function seedIncidentUpdates($incident)
{
$defaultUpdates = [
1 => [
[
'status' => Incident::FIXED,
'message' => 'The monkeys are back and rested!',
'user_id' => 1,
], [
'status' => Incident::WATCHED,
'message' => 'Our monkeys need a break from performing. They\'ll be back after a good rest.',
'user_id' => 1,
], [
'status' => Incident::IDENTIFIED,
'message' => 'We have identified the issue with our lovely performing monkeys.',
'user_id' => 1,
],
],
2 => [
[
'status' => Incident::WATCHED,
'message' => 'We\'re actively watching this issue, so it remains unresolved.',
'user_id' => 1,
],
],
];
$updates = $defaultUpdates[$incident->id];
foreach ($updates as $updateId => $update) {
$update['incident_id'] = $incident->id;
IncidentUpdate::create($update);
}
}
|
[
"protected",
"function",
"seedIncidentUpdates",
"(",
"$",
"incident",
")",
"{",
"$",
"defaultUpdates",
"=",
"[",
"1",
"=>",
"[",
"[",
"'status'",
"=>",
"Incident",
"::",
"FIXED",
",",
"'message'",
"=>",
"'The monkeys are back and rested!'",
",",
"'user_id'",
"=>",
"1",
",",
"]",
",",
"[",
"'status'",
"=>",
"Incident",
"::",
"WATCHED",
",",
"'message'",
"=>",
"'Our monkeys need a break from performing. They\\'ll be back after a good rest.'",
",",
"'user_id'",
"=>",
"1",
",",
"]",
",",
"[",
"'status'",
"=>",
"Incident",
"::",
"IDENTIFIED",
",",
"'message'",
"=>",
"'We have identified the issue with our lovely performing monkeys.'",
",",
"'user_id'",
"=>",
"1",
",",
"]",
",",
"]",
",",
"2",
"=>",
"[",
"[",
"'status'",
"=>",
"Incident",
"::",
"WATCHED",
",",
"'message'",
"=>",
"'We\\'re actively watching this issue, so it remains unresolved.'",
",",
"'user_id'",
"=>",
"1",
",",
"]",
",",
"]",
",",
"]",
";",
"$",
"updates",
"=",
"$",
"defaultUpdates",
"[",
"$",
"incident",
"->",
"id",
"]",
";",
"foreach",
"(",
"$",
"updates",
"as",
"$",
"updateId",
"=>",
"$",
"update",
")",
"{",
"$",
"update",
"[",
"'incident_id'",
"]",
"=",
"$",
"incident",
"->",
"id",
";",
"IncidentUpdate",
"::",
"create",
"(",
"$",
"update",
")",
";",
"}",
"}"
] |
Seed the incident updates table for a given incident.
@return void
|
[
"Seed",
"the",
"incident",
"updates",
"table",
"for",
"a",
"given",
"incident",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/DemoSeederCommand.php#L266-L300
|
220,798
|
CachetHQ/Cachet
|
app/Console/Commands/DemoSeederCommand.php
|
DemoSeederCommand.seedMetrics
|
protected function seedMetrics()
{
$defaultMetrics = [
[
'name' => 'Cups of coffee',
'suffix' => 'Cups',
'description' => 'How many cups of coffee we\'ve drank.',
'default_value' => 0,
'calc_type' => 1,
'display_chart' => 1,
],
];
Metric::truncate();
foreach ($defaultMetrics as $metric) {
Metric::create($metric);
}
}
|
php
|
protected function seedMetrics()
{
$defaultMetrics = [
[
'name' => 'Cups of coffee',
'suffix' => 'Cups',
'description' => 'How many cups of coffee we\'ve drank.',
'default_value' => 0,
'calc_type' => 1,
'display_chart' => 1,
],
];
Metric::truncate();
foreach ($defaultMetrics as $metric) {
Metric::create($metric);
}
}
|
[
"protected",
"function",
"seedMetrics",
"(",
")",
"{",
"$",
"defaultMetrics",
"=",
"[",
"[",
"'name'",
"=>",
"'Cups of coffee'",
",",
"'suffix'",
"=>",
"'Cups'",
",",
"'description'",
"=>",
"'How many cups of coffee we\\'ve drank.'",
",",
"'default_value'",
"=>",
"0",
",",
"'calc_type'",
"=>",
"1",
",",
"'display_chart'",
"=>",
"1",
",",
"]",
",",
"]",
";",
"Metric",
"::",
"truncate",
"(",
")",
";",
"foreach",
"(",
"$",
"defaultMetrics",
"as",
"$",
"metric",
")",
"{",
"Metric",
"::",
"create",
"(",
"$",
"metric",
")",
";",
"}",
"}"
] |
Seed the metrics table.
@return void
|
[
"Seed",
"the",
"metrics",
"table",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/DemoSeederCommand.php#L329-L347
|
220,799
|
CachetHQ/Cachet
|
app/Console/Commands/DemoSeederCommand.php
|
DemoSeederCommand.seedSchedules
|
protected function seedSchedules()
{
$defaultSchedules = [
[
'name' => 'Demo resets every half hour!',
'message' => 'You can schedule downtime for _your_ service!',
'status' => Schedule::UPCOMING,
'scheduled_at' => (new DateTime())->add(new DateInterval('PT2H')),
],
];
Schedule::truncate();
foreach ($defaultSchedules as $schedule) {
Schedule::create($schedule);
}
}
|
php
|
protected function seedSchedules()
{
$defaultSchedules = [
[
'name' => 'Demo resets every half hour!',
'message' => 'You can schedule downtime for _your_ service!',
'status' => Schedule::UPCOMING,
'scheduled_at' => (new DateTime())->add(new DateInterval('PT2H')),
],
];
Schedule::truncate();
foreach ($defaultSchedules as $schedule) {
Schedule::create($schedule);
}
}
|
[
"protected",
"function",
"seedSchedules",
"(",
")",
"{",
"$",
"defaultSchedules",
"=",
"[",
"[",
"'name'",
"=>",
"'Demo resets every half hour!'",
",",
"'message'",
"=>",
"'You can schedule downtime for _your_ service!'",
",",
"'status'",
"=>",
"Schedule",
"::",
"UPCOMING",
",",
"'scheduled_at'",
"=>",
"(",
"new",
"DateTime",
"(",
")",
")",
"->",
"add",
"(",
"new",
"DateInterval",
"(",
"'PT2H'",
")",
")",
",",
"]",
",",
"]",
";",
"Schedule",
"::",
"truncate",
"(",
")",
";",
"foreach",
"(",
"$",
"defaultSchedules",
"as",
"$",
"schedule",
")",
"{",
"Schedule",
"::",
"create",
"(",
"$",
"schedule",
")",
";",
"}",
"}"
] |
Seed the schedules table.
@return void
|
[
"Seed",
"the",
"schedules",
"table",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/DemoSeederCommand.php#L354-L370
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.