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,800
CachetHQ/Cachet
app/Console/Commands/DemoSeederCommand.php
DemoSeederCommand.seedSettings
protected function seedSettings() { $defaultSettings = [ [ 'key' => 'app_name', 'value' => 'Cachet Demo', ], [ 'key' => 'app_domain', 'value' => 'https://demo.cachethq.io', ], [ 'key' => 'show_support', 'value' => '1', ], [ 'key' => 'app_locale', 'value' => 'en', ], [ 'key' => 'app_timezone', 'value' => 'Europe/London', ], [ 'key' => 'app_incident_days', 'value' => '7', ], [ 'key' => 'app_refresh_rate', 'value' => '0', ], [ 'key' => 'app_analytics', 'value' => 'UA-58442674-3', ], [ 'key' => 'app_analytics_gs', 'value' => 'GSN-712462-P', ], [ 'key' => 'display_graphs', 'value' => '1', ], [ 'key' => 'app_about', 'value' => 'This is the demo instance of [Cachet](https://cachethq.io?ref=demo). The open source status page system, for everyone. An [Alt Three](https://alt-three.com) product.', ], [ 'key' => 'enable_subscribers', 'value' => '0', ], ]; $this->settings->clear(); foreach ($defaultSettings as $setting) { $this->settings->set($setting['key'], $setting['value']); } }
php
protected function seedSettings() { $defaultSettings = [ [ 'key' => 'app_name', 'value' => 'Cachet Demo', ], [ 'key' => 'app_domain', 'value' => 'https://demo.cachethq.io', ], [ 'key' => 'show_support', 'value' => '1', ], [ 'key' => 'app_locale', 'value' => 'en', ], [ 'key' => 'app_timezone', 'value' => 'Europe/London', ], [ 'key' => 'app_incident_days', 'value' => '7', ], [ 'key' => 'app_refresh_rate', 'value' => '0', ], [ 'key' => 'app_analytics', 'value' => 'UA-58442674-3', ], [ 'key' => 'app_analytics_gs', 'value' => 'GSN-712462-P', ], [ 'key' => 'display_graphs', 'value' => '1', ], [ 'key' => 'app_about', 'value' => 'This is the demo instance of [Cachet](https://cachethq.io?ref=demo). The open source status page system, for everyone. An [Alt Three](https://alt-three.com) product.', ], [ 'key' => 'enable_subscribers', 'value' => '0', ], ]; $this->settings->clear(); foreach ($defaultSettings as $setting) { $this->settings->set($setting['key'], $setting['value']); } }
[ "protected", "function", "seedSettings", "(", ")", "{", "$", "defaultSettings", "=", "[", "[", "'key'", "=>", "'app_name'", ",", "'value'", "=>", "'Cachet Demo'", ",", "]", ",", "[", "'key'", "=>", "'app_domain'", ",", "'value'", "=>", "'https://demo.cachethq.io'", ",", "]", ",", "[", "'key'", "=>", "'show_support'", ",", "'value'", "=>", "'1'", ",", "]", ",", "[", "'key'", "=>", "'app_locale'", ",", "'value'", "=>", "'en'", ",", "]", ",", "[", "'key'", "=>", "'app_timezone'", ",", "'value'", "=>", "'Europe/London'", ",", "]", ",", "[", "'key'", "=>", "'app_incident_days'", ",", "'value'", "=>", "'7'", ",", "]", ",", "[", "'key'", "=>", "'app_refresh_rate'", ",", "'value'", "=>", "'0'", ",", "]", ",", "[", "'key'", "=>", "'app_analytics'", ",", "'value'", "=>", "'UA-58442674-3'", ",", "]", ",", "[", "'key'", "=>", "'app_analytics_gs'", ",", "'value'", "=>", "'GSN-712462-P'", ",", "]", ",", "[", "'key'", "=>", "'display_graphs'", ",", "'value'", "=>", "'1'", ",", "]", ",", "[", "'key'", "=>", "'app_about'", ",", "'value'", "=>", "'This is the demo instance of [Cachet](https://cachethq.io?ref=demo). The open source status page system, for everyone. An [Alt Three](https://alt-three.com) product.'", ",", "]", ",", "[", "'key'", "=>", "'enable_subscribers'", ",", "'value'", "=>", "'0'", ",", "]", ",", "]", ";", "$", "this", "->", "settings", "->", "clear", "(", ")", ";", "foreach", "(", "$", "defaultSettings", "as", "$", "setting", ")", "{", "$", "this", "->", "settings", "->", "set", "(", "$", "setting", "[", "'key'", "]", ",", "$", "setting", "[", "'value'", "]", ")", ";", "}", "}" ]
Seed the settings table. @return void
[ "Seed", "the", "settings", "table", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/DemoSeederCommand.php#L377-L424
220,801
CachetHQ/Cachet
app/Console/Commands/DemoSeederCommand.php
DemoSeederCommand.seedUsers
protected function seedUsers() { $users = [ [ 'username' => 'test', 'password' => 'test123', 'email' => 'test@example.com', 'level' => User::LEVEL_ADMIN, 'api_key' => '9yMHsdioQosnyVK4iCVR', ], ]; User::truncate(); foreach ($users as $user) { User::create($user); } }
php
protected function seedUsers() { $users = [ [ 'username' => 'test', 'password' => 'test123', 'email' => 'test@example.com', 'level' => User::LEVEL_ADMIN, 'api_key' => '9yMHsdioQosnyVK4iCVR', ], ]; User::truncate(); foreach ($users as $user) { User::create($user); } }
[ "protected", "function", "seedUsers", "(", ")", "{", "$", "users", "=", "[", "[", "'username'", "=>", "'test'", ",", "'password'", "=>", "'test123'", ",", "'email'", "=>", "'test@example.com'", ",", "'level'", "=>", "User", "::", "LEVEL_ADMIN", ",", "'api_key'", "=>", "'9yMHsdioQosnyVK4iCVR'", ",", "]", ",", "]", ";", "User", "::", "truncate", "(", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "User", "::", "create", "(", "$", "user", ")", ";", "}", "}" ]
Seed the users table. @return void
[ "Seed", "the", "users", "table", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Console/Commands/DemoSeederCommand.php#L441-L458
220,802
CachetHQ/Cachet
app/Bus/Handlers/Commands/ComponentGroup/CreateComponentGroupCommandHandler.php
CreateComponentGroupCommandHandler.handle
public function handle(CreateComponentGroupCommand $command) { $group = ComponentGroup::create([ 'name' => $command->name, 'order' => $command->order, 'collapsed' => $command->collapsed, 'visible' => $command->visible, ]); event(new ComponentGroupWasCreatedEvent($this->auth->user(), $group)); return $group; }
php
public function handle(CreateComponentGroupCommand $command) { $group = ComponentGroup::create([ 'name' => $command->name, 'order' => $command->order, 'collapsed' => $command->collapsed, 'visible' => $command->visible, ]); event(new ComponentGroupWasCreatedEvent($this->auth->user(), $group)); return $group; }
[ "public", "function", "handle", "(", "CreateComponentGroupCommand", "$", "command", ")", "{", "$", "group", "=", "ComponentGroup", "::", "create", "(", "[", "'name'", "=>", "$", "command", "->", "name", ",", "'order'", "=>", "$", "command", "->", "order", ",", "'collapsed'", "=>", "$", "command", "->", "collapsed", ",", "'visible'", "=>", "$", "command", "->", "visible", ",", "]", ")", ";", "event", "(", "new", "ComponentGroupWasCreatedEvent", "(", "$", "this", "->", "auth", "->", "user", "(", ")", ",", "$", "group", ")", ")", ";", "return", "$", "group", ";", "}" ]
Handle the create component group command. @param \CachetHQ\Cachet\Bus\Commands\ComponentGroup\CreateComponentGroupCommand $command @return \CachetHQ\Cachet\Models\ComponentGroup
[ "Handle", "the", "create", "component", "group", "command", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/ComponentGroup/CreateComponentGroupCommandHandler.php#L47-L59
220,803
CachetHQ/Cachet
app/Http/Controllers/Api/MetricController.php
MetricController.index
public function index() { $metrics = Metric::query(); if ($sortBy = Binput::get('sort')) { $direction = Binput::has('order') && Binput::get('order') == 'desc'; $metrics->sort($sortBy, $direction); } $metrics = $metrics->paginate(Binput::get('per_page', 20)); return $this->paginator($metrics, Request::instance()); }
php
public function index() { $metrics = Metric::query(); if ($sortBy = Binput::get('sort')) { $direction = Binput::has('order') && Binput::get('order') == 'desc'; $metrics->sort($sortBy, $direction); } $metrics = $metrics->paginate(Binput::get('per_page', 20)); return $this->paginator($metrics, Request::instance()); }
[ "public", "function", "index", "(", ")", "{", "$", "metrics", "=", "Metric", "::", "query", "(", ")", ";", "if", "(", "$", "sortBy", "=", "Binput", "::", "get", "(", "'sort'", ")", ")", "{", "$", "direction", "=", "Binput", "::", "has", "(", "'order'", ")", "&&", "Binput", "::", "get", "(", "'order'", ")", "==", "'desc'", ";", "$", "metrics", "->", "sort", "(", "$", "sortBy", ",", "$", "direction", ")", ";", "}", "$", "metrics", "=", "$", "metrics", "->", "paginate", "(", "Binput", "::", "get", "(", "'per_page'", ",", "20", ")", ")", ";", "return", "$", "this", "->", "paginator", "(", "$", "metrics", ",", "Request", "::", "instance", "(", ")", ")", ";", "}" ]
Get all metrics. @return \Illuminate\Database\Eloquent\Collection
[ "Get", "all", "metrics", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/MetricController.php#L30-L43
220,804
CachetHQ/Cachet
app/Http/Controllers/Api/MetricController.php
MetricController.store
public function store() { try { $metric = execute(new CreateMetricCommand( Binput::get('name'), Binput::get('suffix'), Binput::get('description'), Binput::get('default_value'), Binput::get('calc_type', 0), Binput::get('display_chart', true), Binput::get('places', 2), Binput::get('default_view', Binput::get('view', 1)), Binput::get('threshold', 5), Binput::get('order', 0), Binput::get('visible', 1) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($metric); }
php
public function store() { try { $metric = execute(new CreateMetricCommand( Binput::get('name'), Binput::get('suffix'), Binput::get('description'), Binput::get('default_value'), Binput::get('calc_type', 0), Binput::get('display_chart', true), Binput::get('places', 2), Binput::get('default_view', Binput::get('view', 1)), Binput::get('threshold', 5), Binput::get('order', 0), Binput::get('visible', 1) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($metric); }
[ "public", "function", "store", "(", ")", "{", "try", "{", "$", "metric", "=", "execute", "(", "new", "CreateMetricCommand", "(", "Binput", "::", "get", "(", "'name'", ")", ",", "Binput", "::", "get", "(", "'suffix'", ")", ",", "Binput", "::", "get", "(", "'description'", ")", ",", "Binput", "::", "get", "(", "'default_value'", ")", ",", "Binput", "::", "get", "(", "'calc_type'", ",", "0", ")", ",", "Binput", "::", "get", "(", "'display_chart'", ",", "true", ")", ",", "Binput", "::", "get", "(", "'places'", ",", "2", ")", ",", "Binput", "::", "get", "(", "'default_view'", ",", "Binput", "::", "get", "(", "'view'", ",", "1", ")", ")", ",", "Binput", "::", "get", "(", "'threshold'", ",", "5", ")", ",", "Binput", "::", "get", "(", "'order'", ",", "0", ")", ",", "Binput", "::", "get", "(", "'visible'", ",", "1", ")", ")", ")", ";", "}", "catch", "(", "QueryException", "$", "e", ")", "{", "throw", "new", "BadRequestHttpException", "(", ")", ";", "}", "return", "$", "this", "->", "item", "(", "$", "metric", ")", ";", "}" ]
Create a new metric. @return \Illuminate\Http\JsonResponse
[ "Create", "a", "new", "metric", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/MetricController.php#L62-L83
220,805
CachetHQ/Cachet
app/Http/Controllers/Api/MetricController.php
MetricController.update
public function update(Metric $metric) { try { $metric = execute(new UpdateMetricCommand( $metric, Binput::get('name'), Binput::get('suffix'), Binput::get('description'), Binput::get('default_value'), Binput::get('calc_type'), Binput::get('display_chart'), Binput::get('places'), Binput::get('default_view', Binput::get('view')), Binput::get('threshold'), Binput::get('order'), Binput::get('visible') )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($metric); }
php
public function update(Metric $metric) { try { $metric = execute(new UpdateMetricCommand( $metric, Binput::get('name'), Binput::get('suffix'), Binput::get('description'), Binput::get('default_value'), Binput::get('calc_type'), Binput::get('display_chart'), Binput::get('places'), Binput::get('default_view', Binput::get('view')), Binput::get('threshold'), Binput::get('order'), Binput::get('visible') )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($metric); }
[ "public", "function", "update", "(", "Metric", "$", "metric", ")", "{", "try", "{", "$", "metric", "=", "execute", "(", "new", "UpdateMetricCommand", "(", "$", "metric", ",", "Binput", "::", "get", "(", "'name'", ")", ",", "Binput", "::", "get", "(", "'suffix'", ")", ",", "Binput", "::", "get", "(", "'description'", ")", ",", "Binput", "::", "get", "(", "'default_value'", ")", ",", "Binput", "::", "get", "(", "'calc_type'", ")", ",", "Binput", "::", "get", "(", "'display_chart'", ")", ",", "Binput", "::", "get", "(", "'places'", ")", ",", "Binput", "::", "get", "(", "'default_view'", ",", "Binput", "::", "get", "(", "'view'", ")", ")", ",", "Binput", "::", "get", "(", "'threshold'", ")", ",", "Binput", "::", "get", "(", "'order'", ")", ",", "Binput", "::", "get", "(", "'visible'", ")", ")", ")", ";", "}", "catch", "(", "QueryException", "$", "e", ")", "{", "throw", "new", "BadRequestHttpException", "(", ")", ";", "}", "return", "$", "this", "->", "item", "(", "$", "metric", ")", ";", "}" ]
Update an existing metric. @param \CachetHQ\Cachet\Models\Metric $metric @return \Illuminate\Http\JsonResponse
[ "Update", "an", "existing", "metric", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/MetricController.php#L92-L114
220,806
CachetHQ/Cachet
app/Repositories/Metric/MySqlRepository.php
MySqlRepository.getPointsSinceMinutes
public function getPointsSinceMinutes(Metric $metric, $minutes) { $queryType = $this->getQueryType($metric); $points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d %H:%i') AS `key`, {$queryType} ". "FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ". "WHERE {$this->getMetricsTable()}.id = :metricId ". "AND {$this->getMetricPointsTable()}.`created_at` >= DATE_SUB(NOW(), INTERVAL :minutes MINUTE) ". "AND {$this->getMetricPointsTable()}.`created_at` <= NOW() ". "GROUP BY HOUR({$this->getMetricPointsTable()}.`created_at`), MINUTE({$this->getMetricPointsTable()}.`created_at`) ORDER BY {$this->getMetricPointsTable()}.`created_at`", [ 'metricId' => $metric->id, 'minutes' => $minutes, ]); return $this->mapResults($metric, $points); }
php
public function getPointsSinceMinutes(Metric $metric, $minutes) { $queryType = $this->getQueryType($metric); $points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d %H:%i') AS `key`, {$queryType} ". "FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ". "WHERE {$this->getMetricsTable()}.id = :metricId ". "AND {$this->getMetricPointsTable()}.`created_at` >= DATE_SUB(NOW(), INTERVAL :minutes MINUTE) ". "AND {$this->getMetricPointsTable()}.`created_at` <= NOW() ". "GROUP BY HOUR({$this->getMetricPointsTable()}.`created_at`), MINUTE({$this->getMetricPointsTable()}.`created_at`) ORDER BY {$this->getMetricPointsTable()}.`created_at`", [ 'metricId' => $metric->id, 'minutes' => $minutes, ]); return $this->mapResults($metric, $points); }
[ "public", "function", "getPointsSinceMinutes", "(", "Metric", "$", "metric", ",", "$", "minutes", ")", "{", "$", "queryType", "=", "$", "this", "->", "getQueryType", "(", "$", "metric", ")", ";", "$", "points", "=", "DB", "::", "select", "(", "\"SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d %H:%i') AS `key`, {$queryType} \"", ".", "\"FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id \"", ".", "\"WHERE {$this->getMetricsTable()}.id = :metricId \"", ".", "\"AND {$this->getMetricPointsTable()}.`created_at` >= DATE_SUB(NOW(), INTERVAL :minutes MINUTE) \"", ".", "\"AND {$this->getMetricPointsTable()}.`created_at` <= NOW() \"", ".", "\"GROUP BY HOUR({$this->getMetricPointsTable()}.`created_at`), MINUTE({$this->getMetricPointsTable()}.`created_at`) ORDER BY {$this->getMetricPointsTable()}.`created_at`\"", ",", "[", "'metricId'", "=>", "$", "metric", "->", "id", ",", "'minutes'", "=>", "$", "minutes", ",", "]", ")", ";", "return", "$", "this", "->", "mapResults", "(", "$", "metric", ",", "$", "points", ")", ";", "}" ]
Returns metrics since given minutes. @param \CachetHQ\Cachet\Models\Metric $metric @param int $minutes @return \Illuminate\Support\Collection
[ "Returns", "metrics", "since", "given", "minutes", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Repositories/Metric/MySqlRepository.php#L32-L47
220,807
CachetHQ/Cachet
app/Repositories/Metric/MySqlRepository.php
MySqlRepository.getPointsSinceHour
public function getPointsSinceHour(Metric $metric, $hour) { $queryType = $this->getQueryType($metric); $points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d %H:00') AS `key`, {$queryType} ". "FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ". "WHERE {$this->getMetricsTable()}.id = :metricId ". "AND {$this->getMetricPointsTable()}.`created_at` >= DATE_SUB(NOW(), INTERVAL :hour HOUR) ". "AND {$this->getMetricPointsTable()}.`created_at` <= NOW() ". "GROUP BY HOUR({$this->getMetricPointsTable()}.`created_at`) ". "ORDER BY {$this->getMetricPointsTable()}.`created_at`", [ 'metricId' => $metric->id, 'hour' => $hour, ]); return $this->mapResults($metric, $points); }
php
public function getPointsSinceHour(Metric $metric, $hour) { $queryType = $this->getQueryType($metric); $points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d %H:00') AS `key`, {$queryType} ". "FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ". "WHERE {$this->getMetricsTable()}.id = :metricId ". "AND {$this->getMetricPointsTable()}.`created_at` >= DATE_SUB(NOW(), INTERVAL :hour HOUR) ". "AND {$this->getMetricPointsTable()}.`created_at` <= NOW() ". "GROUP BY HOUR({$this->getMetricPointsTable()}.`created_at`) ". "ORDER BY {$this->getMetricPointsTable()}.`created_at`", [ 'metricId' => $metric->id, 'hour' => $hour, ]); return $this->mapResults($metric, $points); }
[ "public", "function", "getPointsSinceHour", "(", "Metric", "$", "metric", ",", "$", "hour", ")", "{", "$", "queryType", "=", "$", "this", "->", "getQueryType", "(", "$", "metric", ")", ";", "$", "points", "=", "DB", "::", "select", "(", "\"SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d %H:00') AS `key`, {$queryType} \"", ".", "\"FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id \"", ".", "\"WHERE {$this->getMetricsTable()}.id = :metricId \"", ".", "\"AND {$this->getMetricPointsTable()}.`created_at` >= DATE_SUB(NOW(), INTERVAL :hour HOUR) \"", ".", "\"AND {$this->getMetricPointsTable()}.`created_at` <= NOW() \"", ".", "\"GROUP BY HOUR({$this->getMetricPointsTable()}.`created_at`) \"", ".", "\"ORDER BY {$this->getMetricPointsTable()}.`created_at`\"", ",", "[", "'metricId'", "=>", "$", "metric", "->", "id", ",", "'hour'", "=>", "$", "hour", ",", "]", ")", ";", "return", "$", "this", "->", "mapResults", "(", "$", "metric", ",", "$", "points", ")", ";", "}" ]
Returns metrics since given hour. @param \CachetHQ\Cachet\Models\Metric $metric @param int $hour @return \Illuminate\Support\Collection
[ "Returns", "metrics", "since", "given", "hour", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Repositories/Metric/MySqlRepository.php#L57-L72
220,808
CachetHQ/Cachet
app/Repositories/Metric/MySqlRepository.php
MySqlRepository.getPointsSinceDay
public function getPointsSinceDay(Metric $metric, $day) { $queryType = $this->getQueryType($metric); $points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d') AS `key`, {$queryType} ". "FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ". "WHERE {$this->getMetricsTable()}.id = :metricId ". "AND {$this->getMetricPointsTable()}.`created_at` >= DATE_SUB(NOW(), INTERVAL :day DAY) ". "AND {$this->getMetricPointsTable()}.`created_at` <= NOW() ". "GROUP BY DATE({$this->getMetricPointsTable()}.`created_at`) ORDER BY {$this->getMetricPointsTable()}.`created_at`", [ 'metricId' => $metric->id, 'day' => $day, ]); return $this->mapResults($metric, $points); }
php
public function getPointsSinceDay(Metric $metric, $day) { $queryType = $this->getQueryType($metric); $points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d') AS `key`, {$queryType} ". "FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ". "WHERE {$this->getMetricsTable()}.id = :metricId ". "AND {$this->getMetricPointsTable()}.`created_at` >= DATE_SUB(NOW(), INTERVAL :day DAY) ". "AND {$this->getMetricPointsTable()}.`created_at` <= NOW() ". "GROUP BY DATE({$this->getMetricPointsTable()}.`created_at`) ORDER BY {$this->getMetricPointsTable()}.`created_at`", [ 'metricId' => $metric->id, 'day' => $day, ]); return $this->mapResults($metric, $points); }
[ "public", "function", "getPointsSinceDay", "(", "Metric", "$", "metric", ",", "$", "day", ")", "{", "$", "queryType", "=", "$", "this", "->", "getQueryType", "(", "$", "metric", ")", ";", "$", "points", "=", "DB", "::", "select", "(", "\"SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d') AS `key`, {$queryType} \"", ".", "\"FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id \"", ".", "\"WHERE {$this->getMetricsTable()}.id = :metricId \"", ".", "\"AND {$this->getMetricPointsTable()}.`created_at` >= DATE_SUB(NOW(), INTERVAL :day DAY) \"", ".", "\"AND {$this->getMetricPointsTable()}.`created_at` <= NOW() \"", ".", "\"GROUP BY DATE({$this->getMetricPointsTable()}.`created_at`) ORDER BY {$this->getMetricPointsTable()}.`created_at`\"", ",", "[", "'metricId'", "=>", "$", "metric", "->", "id", ",", "'day'", "=>", "$", "day", ",", "]", ")", ";", "return", "$", "this", "->", "mapResults", "(", "$", "metric", ",", "$", "points", ")", ";", "}" ]
Returns metrics since given day. @param \CachetHQ\Cachet\Models\Metric $metric @param int $day @return \Illuminate\Support\Collection
[ "Returns", "metrics", "since", "given", "day", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Repositories/Metric/MySqlRepository.php#L82-L96
220,809
CachetHQ/Cachet
app/Bus/Handlers/Traits/StoresMeta.php
StoresMeta.storeMeta
public function storeMeta($metaData, $metaType, $metaId, $metaModel = Meta::class) { // Validation required instead of type hinting because it could be passed as false or NULL if (!is_array($metaData)) { return; } foreach ($metaData as $key => $value) { $modelInstance = call_user_func( [$metaModel, 'firstOrNew'], [ 'key' => $key, 'meta_type' => $metaType, 'meta_id' => $metaId, ] ); $value = $this->removeEmptyValues($value); if (!empty($value)) { $modelInstance->setAttribute('value', $value); $modelInstance->save(); continue; } // The value is empty, remove the row if ($modelInstance->exists) { $modelInstance->delete(); } } }
php
public function storeMeta($metaData, $metaType, $metaId, $metaModel = Meta::class) { // Validation required instead of type hinting because it could be passed as false or NULL if (!is_array($metaData)) { return; } foreach ($metaData as $key => $value) { $modelInstance = call_user_func( [$metaModel, 'firstOrNew'], [ 'key' => $key, 'meta_type' => $metaType, 'meta_id' => $metaId, ] ); $value = $this->removeEmptyValues($value); if (!empty($value)) { $modelInstance->setAttribute('value', $value); $modelInstance->save(); continue; } // The value is empty, remove the row if ($modelInstance->exists) { $modelInstance->delete(); } } }
[ "public", "function", "storeMeta", "(", "$", "metaData", ",", "$", "metaType", ",", "$", "metaId", ",", "$", "metaModel", "=", "Meta", "::", "class", ")", "{", "// Validation required instead of type hinting because it could be passed as false or NULL", "if", "(", "!", "is_array", "(", "$", "metaData", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "metaData", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "modelInstance", "=", "call_user_func", "(", "[", "$", "metaModel", ",", "'firstOrNew'", "]", ",", "[", "'key'", "=>", "$", "key", ",", "'meta_type'", "=>", "$", "metaType", ",", "'meta_id'", "=>", "$", "metaId", ",", "]", ")", ";", "$", "value", "=", "$", "this", "->", "removeEmptyValues", "(", "$", "value", ")", ";", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "modelInstance", "->", "setAttribute", "(", "'value'", ",", "$", "value", ")", ";", "$", "modelInstance", "->", "save", "(", ")", ";", "continue", ";", "}", "// The value is empty, remove the row", "if", "(", "$", "modelInstance", "->", "exists", ")", "{", "$", "modelInstance", "->", "delete", "(", ")", ";", "}", "}", "}" ]
Stores all Meta values of a model. @param array $metaData @param string $metaType @param string|int $metaId @param string $metaModel @return void
[ "Stores", "all", "Meta", "values", "of", "a", "model", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Traits/StoresMeta.php#L28-L57
220,810
CachetHQ/Cachet
app/Bus/Handlers/Traits/StoresMeta.php
StoresMeta.removeEmptyValues
protected function removeEmptyValues($values) { if (!is_array($values)) { return empty($values) ? null : $values; } foreach ($values as $key => $value) { if (!empty($value)) { continue; } unset($values[$key]); } return $values; }
php
protected function removeEmptyValues($values) { if (!is_array($values)) { return empty($values) ? null : $values; } foreach ($values as $key => $value) { if (!empty($value)) { continue; } unset($values[$key]); } return $values; }
[ "protected", "function", "removeEmptyValues", "(", "$", "values", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "return", "empty", "(", "$", "values", ")", "?", "null", ":", "$", "values", ";", "}", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "continue", ";", "}", "unset", "(", "$", "values", "[", "$", "key", "]", ")", ";", "}", "return", "$", "values", ";", "}" ]
Determine if a Value is empty. @param mixed $values @return array|mixed
[ "Determine", "if", "a", "Value", "is", "empty", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Traits/StoresMeta.php#L66-L80
220,811
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ApiController.php
ApiController.postUpdateComponent
public function postUpdateComponent(Component $component) { try { execute(new UpdateComponentCommand( $component, $component->name, $component->description, Binput::get('status'), $component->link, $component->order, $component->group_id, $component->enabled, $component->meta, false )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($component); }
php
public function postUpdateComponent(Component $component) { try { execute(new UpdateComponentCommand( $component, $component->name, $component->description, Binput::get('status'), $component->link, $component->order, $component->group_id, $component->enabled, $component->meta, false )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($component); }
[ "public", "function", "postUpdateComponent", "(", "Component", "$", "component", ")", "{", "try", "{", "execute", "(", "new", "UpdateComponentCommand", "(", "$", "component", ",", "$", "component", "->", "name", ",", "$", "component", "->", "description", ",", "Binput", "::", "get", "(", "'status'", ")", ",", "$", "component", "->", "link", ",", "$", "component", "->", "order", ",", "$", "component", "->", "group_id", ",", "$", "component", "->", "enabled", ",", "$", "component", "->", "meta", ",", "false", ")", ")", ";", "}", "catch", "(", "QueryException", "$", "e", ")", "{", "throw", "new", "BadRequestHttpException", "(", ")", ";", "}", "return", "$", "this", "->", "item", "(", "$", "component", ")", ";", "}" ]
Updates a component with the entered info. @param \CachetHQ\Cachet\Models\Component $component @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException @return \CachetHQ\Cachet\Models\Component
[ "Updates", "a", "component", "with", "the", "entered", "info", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ApiController.php#L36-L56
220,812
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ApiController.php
ApiController.postUpdateComponentOrder
public function postUpdateComponentOrder() { $componentData = Binput::get('ids'); foreach ($componentData as $order => $componentId) { try { $component = Component::find($componentId); execute(new UpdateComponentCommand( $component, $component->name, $component->description, $component->status, $component->link, $order + 1, $component->group_id, $component->enabled, $component->meta, true )); } catch (QueryException $e) { throw new BadRequestHttpException(); } } return $this->collection(Component::query()->orderBy('order')->get()); }
php
public function postUpdateComponentOrder() { $componentData = Binput::get('ids'); foreach ($componentData as $order => $componentId) { try { $component = Component::find($componentId); execute(new UpdateComponentCommand( $component, $component->name, $component->description, $component->status, $component->link, $order + 1, $component->group_id, $component->enabled, $component->meta, true )); } catch (QueryException $e) { throw new BadRequestHttpException(); } } return $this->collection(Component::query()->orderBy('order')->get()); }
[ "public", "function", "postUpdateComponentOrder", "(", ")", "{", "$", "componentData", "=", "Binput", "::", "get", "(", "'ids'", ")", ";", "foreach", "(", "$", "componentData", "as", "$", "order", "=>", "$", "componentId", ")", "{", "try", "{", "$", "component", "=", "Component", "::", "find", "(", "$", "componentId", ")", ";", "execute", "(", "new", "UpdateComponentCommand", "(", "$", "component", ",", "$", "component", "->", "name", ",", "$", "component", "->", "description", ",", "$", "component", "->", "status", ",", "$", "component", "->", "link", ",", "$", "order", "+", "1", ",", "$", "component", "->", "group_id", ",", "$", "component", "->", "enabled", ",", "$", "component", "->", "meta", ",", "true", ")", ")", ";", "}", "catch", "(", "QueryException", "$", "e", ")", "{", "throw", "new", "BadRequestHttpException", "(", ")", ";", "}", "}", "return", "$", "this", "->", "collection", "(", "Component", "::", "query", "(", ")", "->", "orderBy", "(", "'order'", ")", "->", "get", "(", ")", ")", ";", "}" ]
Updates a components ordering. @return array
[ "Updates", "a", "components", "ordering", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ApiController.php#L63-L89
220,813
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ApiController.php
ApiController.postUpdateComponentGroupOrder
public function postUpdateComponentGroupOrder() { $groupData = Binput::get('ids'); foreach ($groupData as $order => $groupId) { $group = ComponentGroup::find($groupId); execute(new UpdateComponentGroupCommand( $group, $group->name, $order + 1, $group->collapsed, $group->visible )); } return $this->collection(ComponentGroup::query()->orderBy('order')->get()); }
php
public function postUpdateComponentGroupOrder() { $groupData = Binput::get('ids'); foreach ($groupData as $order => $groupId) { $group = ComponentGroup::find($groupId); execute(new UpdateComponentGroupCommand( $group, $group->name, $order + 1, $group->collapsed, $group->visible )); } return $this->collection(ComponentGroup::query()->orderBy('order')->get()); }
[ "public", "function", "postUpdateComponentGroupOrder", "(", ")", "{", "$", "groupData", "=", "Binput", "::", "get", "(", "'ids'", ")", ";", "foreach", "(", "$", "groupData", "as", "$", "order", "=>", "$", "groupId", ")", "{", "$", "group", "=", "ComponentGroup", "::", "find", "(", "$", "groupId", ")", ";", "execute", "(", "new", "UpdateComponentGroupCommand", "(", "$", "group", ",", "$", "group", "->", "name", ",", "$", "order", "+", "1", ",", "$", "group", "->", "collapsed", ",", "$", "group", "->", "visible", ")", ")", ";", "}", "return", "$", "this", "->", "collection", "(", "ComponentGroup", "::", "query", "(", ")", "->", "orderBy", "(", "'order'", ")", "->", "get", "(", ")", ")", ";", "}" ]
Updates the order of component groups. @return array
[ "Updates", "the", "order", "of", "component", "groups", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ApiController.php#L96-L113
220,814
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ApiController.php
ApiController.getIncidentTemplate
public function getIncidentTemplate() { $templateSlug = Binput::get('slug'); if ($template = IncidentTemplate::where('slug', '=', $templateSlug)->first()) { return $template; } throw new ModelNotFoundException("Incident template for $templateSlug could not be found."); }
php
public function getIncidentTemplate() { $templateSlug = Binput::get('slug'); if ($template = IncidentTemplate::where('slug', '=', $templateSlug)->first()) { return $template; } throw new ModelNotFoundException("Incident template for $templateSlug could not be found."); }
[ "public", "function", "getIncidentTemplate", "(", ")", "{", "$", "templateSlug", "=", "Binput", "::", "get", "(", "'slug'", ")", ";", "if", "(", "$", "template", "=", "IncidentTemplate", "::", "where", "(", "'slug'", ",", "'='", ",", "$", "templateSlug", ")", "->", "first", "(", ")", ")", "{", "return", "$", "template", ";", "}", "throw", "new", "ModelNotFoundException", "(", "\"Incident template for $templateSlug could not be found.\"", ")", ";", "}" ]
Returns a template by slug. @throws \Illuminate\Database\Eloquent\ModelNotFoundException @return \CachetHQ\Cachet\Models\IncidentTemplate
[ "Returns", "a", "template", "by", "slug", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ApiController.php#L122-L131
220,815
CachetHQ/Cachet
app/Http/Controllers/Api/IncidentController.php
IncidentController.index
public function index() { $incidentVisibility = app(Guard::class)->check() ? 0 : 1; $incidents = Incident::where('visible', '>=', $incidentVisibility); $incidents->search(Binput::except(['sort', 'order', 'per_page'])); if ($sortBy = Binput::get('sort')) { $direction = Binput::has('order') && Binput::get('order') == 'desc'; $incidents->sort($sortBy, $direction); } $incidents = $incidents->paginate(Binput::get('per_page', 20)); return $this->paginator($incidents, Request::instance()); }
php
public function index() { $incidentVisibility = app(Guard::class)->check() ? 0 : 1; $incidents = Incident::where('visible', '>=', $incidentVisibility); $incidents->search(Binput::except(['sort', 'order', 'per_page'])); if ($sortBy = Binput::get('sort')) { $direction = Binput::has('order') && Binput::get('order') == 'desc'; $incidents->sort($sortBy, $direction); } $incidents = $incidents->paginate(Binput::get('per_page', 20)); return $this->paginator($incidents, Request::instance()); }
[ "public", "function", "index", "(", ")", "{", "$", "incidentVisibility", "=", "app", "(", "Guard", "::", "class", ")", "->", "check", "(", ")", "?", "0", ":", "1", ";", "$", "incidents", "=", "Incident", "::", "where", "(", "'visible'", ",", "'>='", ",", "$", "incidentVisibility", ")", ";", "$", "incidents", "->", "search", "(", "Binput", "::", "except", "(", "[", "'sort'", ",", "'order'", ",", "'per_page'", "]", ")", ")", ";", "if", "(", "$", "sortBy", "=", "Binput", "::", "get", "(", "'sort'", ")", ")", "{", "$", "direction", "=", "Binput", "::", "has", "(", "'order'", ")", "&&", "Binput", "::", "get", "(", "'order'", ")", "==", "'desc'", ";", "$", "incidents", "->", "sort", "(", "$", "sortBy", ",", "$", "direction", ")", ";", "}", "$", "incidents", "=", "$", "incidents", "->", "paginate", "(", "Binput", "::", "get", "(", "'per_page'", ",", "20", ")", ")", ";", "return", "$", "this", "->", "paginator", "(", "$", "incidents", ",", "Request", "::", "instance", "(", ")", ")", ";", "}" ]
Get all incidents. @return \Illuminate\Http\JsonResponse
[ "Get", "all", "incidents", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/IncidentController.php#L31-L48
220,816
CachetHQ/Cachet
app/Http/Controllers/Api/IncidentController.php
IncidentController.store
public function store() { try { $incident = execute(new CreateIncidentCommand( Binput::get('name'), Binput::get('status'), Binput::get('message', null, false, false), (bool) Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), (bool) Binput::get('notify', true), (bool) Binput::get('stickied', false), Binput::get('occurred_at'), Binput::get('template'), Binput::get('vars', []), Binput::get('meta', []) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($incident); }
php
public function store() { try { $incident = execute(new CreateIncidentCommand( Binput::get('name'), Binput::get('status'), Binput::get('message', null, false, false), (bool) Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), (bool) Binput::get('notify', true), (bool) Binput::get('stickied', false), Binput::get('occurred_at'), Binput::get('template'), Binput::get('vars', []), Binput::get('meta', []) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($incident); }
[ "public", "function", "store", "(", ")", "{", "try", "{", "$", "incident", "=", "execute", "(", "new", "CreateIncidentCommand", "(", "Binput", "::", "get", "(", "'name'", ")", ",", "Binput", "::", "get", "(", "'status'", ")", ",", "Binput", "::", "get", "(", "'message'", ",", "null", ",", "false", ",", "false", ")", ",", "(", "bool", ")", "Binput", "::", "get", "(", "'visible'", ",", "true", ")", ",", "Binput", "::", "get", "(", "'component_id'", ")", ",", "Binput", "::", "get", "(", "'component_status'", ")", ",", "(", "bool", ")", "Binput", "::", "get", "(", "'notify'", ",", "true", ")", ",", "(", "bool", ")", "Binput", "::", "get", "(", "'stickied'", ",", "false", ")", ",", "Binput", "::", "get", "(", "'occurred_at'", ")", ",", "Binput", "::", "get", "(", "'template'", ")", ",", "Binput", "::", "get", "(", "'vars'", ",", "[", "]", ")", ",", "Binput", "::", "get", "(", "'meta'", ",", "[", "]", ")", ")", ")", ";", "}", "catch", "(", "QueryException", "$", "e", ")", "{", "throw", "new", "BadRequestHttpException", "(", ")", ";", "}", "return", "$", "this", "->", "item", "(", "$", "incident", ")", ";", "}" ]
Create a new incident. @return \Illuminate\Http\JsonResponse
[ "Create", "a", "new", "incident", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/IncidentController.php#L67-L89
220,817
CachetHQ/Cachet
app/Http/Controllers/Api/IncidentController.php
IncidentController.update
public function update(Incident $incident) { try { $incident = execute(new UpdateIncidentCommand( $incident, Binput::get('name'), Binput::get('status'), Binput::get('message'), (bool) Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), (bool) Binput::get('notify', true), (bool) Binput::get('stickied', false), Binput::get('occurred_at'), Binput::get('template'), Binput::get('vars', []) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($incident); }
php
public function update(Incident $incident) { try { $incident = execute(new UpdateIncidentCommand( $incident, Binput::get('name'), Binput::get('status'), Binput::get('message'), (bool) Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), (bool) Binput::get('notify', true), (bool) Binput::get('stickied', false), Binput::get('occurred_at'), Binput::get('template'), Binput::get('vars', []) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($incident); }
[ "public", "function", "update", "(", "Incident", "$", "incident", ")", "{", "try", "{", "$", "incident", "=", "execute", "(", "new", "UpdateIncidentCommand", "(", "$", "incident", ",", "Binput", "::", "get", "(", "'name'", ")", ",", "Binput", "::", "get", "(", "'status'", ")", ",", "Binput", "::", "get", "(", "'message'", ")", ",", "(", "bool", ")", "Binput", "::", "get", "(", "'visible'", ",", "true", ")", ",", "Binput", "::", "get", "(", "'component_id'", ")", ",", "Binput", "::", "get", "(", "'component_status'", ")", ",", "(", "bool", ")", "Binput", "::", "get", "(", "'notify'", ",", "true", ")", ",", "(", "bool", ")", "Binput", "::", "get", "(", "'stickied'", ",", "false", ")", ",", "Binput", "::", "get", "(", "'occurred_at'", ")", ",", "Binput", "::", "get", "(", "'template'", ")", ",", "Binput", "::", "get", "(", "'vars'", ",", "[", "]", ")", ")", ")", ";", "}", "catch", "(", "QueryException", "$", "e", ")", "{", "throw", "new", "BadRequestHttpException", "(", ")", ";", "}", "return", "$", "this", "->", "item", "(", "$", "incident", ")", ";", "}" ]
Update an existing incident. @param \CachetHQ\Cachet\Models\Incident $incident @return \Illuminate\Http\JsonResponse
[ "Update", "an", "existing", "incident", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/IncidentController.php#L98-L120
220,818
CachetHQ/Cachet
app/Bus/Handlers/Jobs/System/SendBeaconJobHandler.php
SendBeaconJobHandler.handle
public function handle(SendBeaconJob $job) { // Don't send anything if the installation explicitly prevents us. if (!$this->beacon->enabled()) { return; } try { $this->beacon->send(); } catch (Exception $e) { // } }
php
public function handle(SendBeaconJob $job) { // Don't send anything if the installation explicitly prevents us. if (!$this->beacon->enabled()) { return; } try { $this->beacon->send(); } catch (Exception $e) { // } }
[ "public", "function", "handle", "(", "SendBeaconJob", "$", "job", ")", "{", "// Don't send anything if the installation explicitly prevents us.", "if", "(", "!", "$", "this", "->", "beacon", "->", "enabled", "(", ")", ")", "{", "return", ";", "}", "try", "{", "$", "this", "->", "beacon", "->", "send", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "//", "}", "}" ]
Handle the send beacon job. @param \CachetHQ\Cachet\Bus\Jobs\System\SendBeaconJob $job @return void
[ "Handle", "the", "send", "beacon", "job", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Jobs/System/SendBeaconJobHandler.php#L51-L63
220,819
CachetHQ/Cachet
app/Bus/Handlers/Commands/ComponentGroup/RemoveComponentGroupCommandHandler.php
RemoveComponentGroupCommandHandler.handle
public function handle(RemoveComponentGroupCommand $command) { $group = $command->group; event(new ComponentGroupWasRemovedEvent($this->auth->user(), $group)); // Remove the group id from all component. $group->components->map(function ($component) { $component->update(['group_id' => 0]); }); $group->delete(); }
php
public function handle(RemoveComponentGroupCommand $command) { $group = $command->group; event(new ComponentGroupWasRemovedEvent($this->auth->user(), $group)); // Remove the group id from all component. $group->components->map(function ($component) { $component->update(['group_id' => 0]); }); $group->delete(); }
[ "public", "function", "handle", "(", "RemoveComponentGroupCommand", "$", "command", ")", "{", "$", "group", "=", "$", "command", "->", "group", ";", "event", "(", "new", "ComponentGroupWasRemovedEvent", "(", "$", "this", "->", "auth", "->", "user", "(", ")", ",", "$", "group", ")", ")", ";", "// Remove the group id from all component.", "$", "group", "->", "components", "->", "map", "(", "function", "(", "$", "component", ")", "{", "$", "component", "->", "update", "(", "[", "'group_id'", "=>", "0", "]", ")", ";", "}", ")", ";", "$", "group", "->", "delete", "(", ")", ";", "}" ]
Handle the remove component group command. @param \CachetHQ\Cachet\Bus\Commands\ComponentGroup\RemoveComponentGroupCommand $command @return void
[ "Handle", "the", "remove", "component", "group", "command", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/ComponentGroup/RemoveComponentGroupCommandHandler.php#L46-L58
220,820
CachetHQ/Cachet
app/Bus/Handlers/Commands/Metric/UpdateMetricCommandHandler.php
UpdateMetricCommandHandler.handle
public function handle(UpdateMetricCommand $command) { $metric = $command->metric; $metric->update($this->filter($command)); event(new MetricWasUpdatedEvent($this->auth->user(), $metric)); return $metric; }
php
public function handle(UpdateMetricCommand $command) { $metric = $command->metric; $metric->update($this->filter($command)); event(new MetricWasUpdatedEvent($this->auth->user(), $metric)); return $metric; }
[ "public", "function", "handle", "(", "UpdateMetricCommand", "$", "command", ")", "{", "$", "metric", "=", "$", "command", "->", "metric", ";", "$", "metric", "->", "update", "(", "$", "this", "->", "filter", "(", "$", "command", ")", ")", ";", "event", "(", "new", "MetricWasUpdatedEvent", "(", "$", "this", "->", "auth", "->", "user", "(", ")", ",", "$", "metric", ")", ")", ";", "return", "$", "metric", ";", "}" ]
Handle the update metric command. @param \CachetHQ\Cachet\Bus\Commands\Metric\UpdateMetricCommand $command @return \CachetHQ\Cachet\Models\Metric
[ "Handle", "the", "update", "metric", "command", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Metric/UpdateMetricCommandHandler.php#L47-L56
220,821
CachetHQ/Cachet
app/Http/Controllers/Api/GeneralController.php
GeneralController.version
public function version() { $latest = app()->make(Releases::class)->latest(); return $this->setMetaData([ 'on_latest' => version_compare(CACHET_VERSION, $latest['tag_name']) === 1, 'latest' => $latest, ])->item(CACHET_VERSION); }
php
public function version() { $latest = app()->make(Releases::class)->latest(); return $this->setMetaData([ 'on_latest' => version_compare(CACHET_VERSION, $latest['tag_name']) === 1, 'latest' => $latest, ])->item(CACHET_VERSION); }
[ "public", "function", "version", "(", ")", "{", "$", "latest", "=", "app", "(", ")", "->", "make", "(", "Releases", "::", "class", ")", "->", "latest", "(", ")", ";", "return", "$", "this", "->", "setMetaData", "(", "[", "'on_latest'", "=>", "version_compare", "(", "CACHET_VERSION", ",", "$", "latest", "[", "'tag_name'", "]", ")", "===", "1", ",", "'latest'", "=>", "$", "latest", ",", "]", ")", "->", "item", "(", "CACHET_VERSION", ")", ";", "}" ]
Endpoint to show the Cachet version. @return \Illuminate\Http\JsonResponse
[ "Endpoint", "to", "show", "the", "Cachet", "version", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/GeneralController.php#L39-L47
220,822
CachetHQ/Cachet
app/Http/Controllers/Api/GeneralController.php
GeneralController.status
public function status() { $system = app()->make(System::class)->getStatus(); return $this->item([ 'status' => $system['system_status'], 'message' => $system['system_message'], ]); }
php
public function status() { $system = app()->make(System::class)->getStatus(); return $this->item([ 'status' => $system['system_status'], 'message' => $system['system_message'], ]); }
[ "public", "function", "status", "(", ")", "{", "$", "system", "=", "app", "(", ")", "->", "make", "(", "System", "::", "class", ")", "->", "getStatus", "(", ")", ";", "return", "$", "this", "->", "item", "(", "[", "'status'", "=>", "$", "system", "[", "'system_status'", "]", ",", "'message'", "=>", "$", "system", "[", "'system_message'", "]", ",", "]", ")", ";", "}" ]
Get the system status message. @return \Illuminate\Http\JsonResponse
[ "Get", "the", "system", "status", "message", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/GeneralController.php#L54-L62
220,823
CachetHQ/Cachet
app/Http/Controllers/AuthController.php
AuthController.postLogin
public function postLogin() { $loginData = Binput::only(['username', 'password', 'remember_me']); // Login with username or email. $loginKey = filter_var($loginData['username'], FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; $loginData[$loginKey] = Arr::pull($loginData, 'username'); $rememberUser = Arr::pull($loginData, 'remember_me') === '1'; // Validate login credentials. if (Auth::validate($loginData)) { Auth::once($loginData); if (Auth::user()->hasTwoFactor) { Session::put('2fa_id', Auth::user()->id); return cachet_redirect('auth.two-factor'); } Auth::attempt($loginData, $rememberUser); event(new UserLoggedInEvent(Auth::user())); return Redirect::intended(cachet_route('dashboard')); } return cachet_redirect('auth.login') ->withInput(Binput::except('password')) ->withError(trans('forms.login.invalid')); }
php
public function postLogin() { $loginData = Binput::only(['username', 'password', 'remember_me']); // Login with username or email. $loginKey = filter_var($loginData['username'], FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; $loginData[$loginKey] = Arr::pull($loginData, 'username'); $rememberUser = Arr::pull($loginData, 'remember_me') === '1'; // Validate login credentials. if (Auth::validate($loginData)) { Auth::once($loginData); if (Auth::user()->hasTwoFactor) { Session::put('2fa_id', Auth::user()->id); return cachet_redirect('auth.two-factor'); } Auth::attempt($loginData, $rememberUser); event(new UserLoggedInEvent(Auth::user())); return Redirect::intended(cachet_route('dashboard')); } return cachet_redirect('auth.login') ->withInput(Binput::except('password')) ->withError(trans('forms.login.invalid')); }
[ "public", "function", "postLogin", "(", ")", "{", "$", "loginData", "=", "Binput", "::", "only", "(", "[", "'username'", ",", "'password'", ",", "'remember_me'", "]", ")", ";", "// Login with username or email.", "$", "loginKey", "=", "filter_var", "(", "$", "loginData", "[", "'username'", "]", ",", "FILTER_VALIDATE_EMAIL", ")", "?", "'email'", ":", "'username'", ";", "$", "loginData", "[", "$", "loginKey", "]", "=", "Arr", "::", "pull", "(", "$", "loginData", ",", "'username'", ")", ";", "$", "rememberUser", "=", "Arr", "::", "pull", "(", "$", "loginData", ",", "'remember_me'", ")", "===", "'1'", ";", "// Validate login credentials.", "if", "(", "Auth", "::", "validate", "(", "$", "loginData", ")", ")", "{", "Auth", "::", "once", "(", "$", "loginData", ")", ";", "if", "(", "Auth", "::", "user", "(", ")", "->", "hasTwoFactor", ")", "{", "Session", "::", "put", "(", "'2fa_id'", ",", "Auth", "::", "user", "(", ")", "->", "id", ")", ";", "return", "cachet_redirect", "(", "'auth.two-factor'", ")", ";", "}", "Auth", "::", "attempt", "(", "$", "loginData", ",", "$", "rememberUser", ")", ";", "event", "(", "new", "UserLoggedInEvent", "(", "Auth", "::", "user", "(", ")", ")", ")", ";", "return", "Redirect", "::", "intended", "(", "cachet_route", "(", "'dashboard'", ")", ")", ";", "}", "return", "cachet_redirect", "(", "'auth.login'", ")", "->", "withInput", "(", "Binput", "::", "except", "(", "'password'", ")", ")", "->", "withError", "(", "trans", "(", "'forms.login.invalid'", ")", ")", ";", "}" ]
Logs the user in. @return \Illuminate\Http\RedirectResponse
[ "Logs", "the", "user", "in", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/AuthController.php#L45-L75
220,824
CachetHQ/Cachet
app/Http/Controllers/AuthController.php
AuthController.postTwoFactor
public function postTwoFactor() { // Check that we have a session. if ($userId = Session::pull('2fa_id')) { $code = str_replace(' ', '', Binput::get('code')); // Maybe a temp login here. Auth::loginUsingId($userId); $user = Auth::user(); $valid = Google2FA::verifyKey($user->google_2fa_secret, $code); if ($valid) { event(new UserPassedTwoAuthEvent($user)); event(new UserLoggedInEvent($user)); return Redirect::intended('dashboard'); } else { event(new UserFailedTwoAuthEvent($user)); // Failed login, log back out. Auth::logout(); return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token')); } } return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token')); }
php
public function postTwoFactor() { // Check that we have a session. if ($userId = Session::pull('2fa_id')) { $code = str_replace(' ', '', Binput::get('code')); // Maybe a temp login here. Auth::loginUsingId($userId); $user = Auth::user(); $valid = Google2FA::verifyKey($user->google_2fa_secret, $code); if ($valid) { event(new UserPassedTwoAuthEvent($user)); event(new UserLoggedInEvent($user)); return Redirect::intended('dashboard'); } else { event(new UserFailedTwoAuthEvent($user)); // Failed login, log back out. Auth::logout(); return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token')); } } return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token')); }
[ "public", "function", "postTwoFactor", "(", ")", "{", "// Check that we have a session.", "if", "(", "$", "userId", "=", "Session", "::", "pull", "(", "'2fa_id'", ")", ")", "{", "$", "code", "=", "str_replace", "(", "' '", ",", "''", ",", "Binput", "::", "get", "(", "'code'", ")", ")", ";", "// Maybe a temp login here.", "Auth", "::", "loginUsingId", "(", "$", "userId", ")", ";", "$", "user", "=", "Auth", "::", "user", "(", ")", ";", "$", "valid", "=", "Google2FA", "::", "verifyKey", "(", "$", "user", "->", "google_2fa_secret", ",", "$", "code", ")", ";", "if", "(", "$", "valid", ")", "{", "event", "(", "new", "UserPassedTwoAuthEvent", "(", "$", "user", ")", ")", ";", "event", "(", "new", "UserLoggedInEvent", "(", "$", "user", ")", ")", ";", "return", "Redirect", "::", "intended", "(", "'dashboard'", ")", ";", "}", "else", "{", "event", "(", "new", "UserFailedTwoAuthEvent", "(", "$", "user", ")", ")", ";", "// Failed login, log back out.", "Auth", "::", "logout", "(", ")", ";", "return", "cachet_redirect", "(", "'auth.login'", ")", "->", "withError", "(", "trans", "(", "'forms.login.invalid-token'", ")", ")", ";", "}", "}", "return", "cachet_redirect", "(", "'auth.login'", ")", "->", "withError", "(", "trans", "(", "'forms.login.invalid-token'", ")", ")", ";", "}" ]
Validates the Two Factor token. This feels very hacky, but we have to juggle authentication and codes. @return \Illuminate\Http\RedirectResponse
[ "Validates", "the", "Two", "Factor", "token", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/AuthController.php#L94-L124
220,825
CachetHQ/Cachet
app/Foundation/Providers/AppServiceProvider.php
AppServiceProvider.registerDateFactory
protected function registerDateFactory() { $this->app->singleton(DateFactory::class, function ($app) { $appTimezone = $app['config']->get('app.timezone'); $cacheTimezone = $app['config']->get('cachet.timezone'); return new DateFactory($appTimezone, $cacheTimezone); }); }
php
protected function registerDateFactory() { $this->app->singleton(DateFactory::class, function ($app) { $appTimezone = $app['config']->get('app.timezone'); $cacheTimezone = $app['config']->get('cachet.timezone'); return new DateFactory($appTimezone, $cacheTimezone); }); }
[ "protected", "function", "registerDateFactory", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "DateFactory", "::", "class", ",", "function", "(", "$", "app", ")", "{", "$", "appTimezone", "=", "$", "app", "[", "'config'", "]", "->", "get", "(", "'app.timezone'", ")", ";", "$", "cacheTimezone", "=", "$", "app", "[", "'config'", "]", "->", "get", "(", "'cachet.timezone'", ")", ";", "return", "new", "DateFactory", "(", "$", "appTimezone", ",", "$", "cacheTimezone", ")", ";", "}", ")", ";", "}" ]
Register the date factory. @return void
[ "Register", "the", "date", "factory", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Foundation/Providers/AppServiceProvider.php#L78-L86
220,826
CachetHQ/Cachet
app/Repositories/Metric/MetricRepository.php
MetricRepository.listPointsLastHour
public function listPointsLastHour(Metric $metric) { $dateTime = $this->dates->make(); $pointKey = $dateTime->format('Y-m-d H:i'); $nrOfMinutes = 61; $points = $this->repository->getPointsSinceMinutes($metric, $nrOfMinutes + $metric->threshold)->pluck('value', 'key')->take(-$nrOfMinutes); $timeframe = $nrOfMinutes; for ($i = 0; $i < $timeframe; $i++) { if (!$points->has($pointKey)) { if ($i >= $metric->threshold) { $points->put($pointKey, $metric->default_value); } else { // The point not found is still within the threshold, so it is ignored and // the timeframe is shifted by one minute $timeframe++; } } $pointKey = $dateTime->sub(new DateInterval('PT1M'))->format('Y-m-d H:i'); } return $points->sortBy(function ($point, $key) { return $key; }); }
php
public function listPointsLastHour(Metric $metric) { $dateTime = $this->dates->make(); $pointKey = $dateTime->format('Y-m-d H:i'); $nrOfMinutes = 61; $points = $this->repository->getPointsSinceMinutes($metric, $nrOfMinutes + $metric->threshold)->pluck('value', 'key')->take(-$nrOfMinutes); $timeframe = $nrOfMinutes; for ($i = 0; $i < $timeframe; $i++) { if (!$points->has($pointKey)) { if ($i >= $metric->threshold) { $points->put($pointKey, $metric->default_value); } else { // The point not found is still within the threshold, so it is ignored and // the timeframe is shifted by one minute $timeframe++; } } $pointKey = $dateTime->sub(new DateInterval('PT1M'))->format('Y-m-d H:i'); } return $points->sortBy(function ($point, $key) { return $key; }); }
[ "public", "function", "listPointsLastHour", "(", "Metric", "$", "metric", ")", "{", "$", "dateTime", "=", "$", "this", "->", "dates", "->", "make", "(", ")", ";", "$", "pointKey", "=", "$", "dateTime", "->", "format", "(", "'Y-m-d H:i'", ")", ";", "$", "nrOfMinutes", "=", "61", ";", "$", "points", "=", "$", "this", "->", "repository", "->", "getPointsSinceMinutes", "(", "$", "metric", ",", "$", "nrOfMinutes", "+", "$", "metric", "->", "threshold", ")", "->", "pluck", "(", "'value'", ",", "'key'", ")", "->", "take", "(", "-", "$", "nrOfMinutes", ")", ";", "$", "timeframe", "=", "$", "nrOfMinutes", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "timeframe", ";", "$", "i", "++", ")", "{", "if", "(", "!", "$", "points", "->", "has", "(", "$", "pointKey", ")", ")", "{", "if", "(", "$", "i", ">=", "$", "metric", "->", "threshold", ")", "{", "$", "points", "->", "put", "(", "$", "pointKey", ",", "$", "metric", "->", "default_value", ")", ";", "}", "else", "{", "// The point not found is still within the threshold, so it is ignored and", "// the timeframe is shifted by one minute", "$", "timeframe", "++", ";", "}", "}", "$", "pointKey", "=", "$", "dateTime", "->", "sub", "(", "new", "DateInterval", "(", "'PT1M'", ")", ")", "->", "format", "(", "'Y-m-d H:i'", ")", ";", "}", "return", "$", "points", "->", "sortBy", "(", "function", "(", "$", "point", ",", "$", "key", ")", "{", "return", "$", "key", ";", "}", ")", ";", "}" ]
Returns all points as an array, for the last hour. @param \CachetHQ\Cachet\Models\Metric $metric @return \Illuminate\Support\Collection
[ "Returns", "all", "points", "as", "an", "array", "for", "the", "last", "hour", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Repositories/Metric/MetricRepository.php#L60-L85
220,827
CachetHQ/Cachet
app/Repositories/Metric/MetricRepository.php
MetricRepository.listPointsToday
public function listPointsToday(Metric $metric, $hours = 12) { $dateTime = $this->dates->make(); $pointKey = $dateTime->format('Y-m-d H:00'); $points = $this->repository->getPointsSinceHour($metric, $hours)->pluck('value', 'key'); for ($i = 0; $i < $hours; $i++) { if (!$points->has($pointKey)) { $points->put($pointKey, $metric->default_value); } $pointKey = $dateTime->sub(new DateInterval('PT1H'))->format('Y-m-d H:00'); } return $points->sortBy(function ($point, $key) { return $key; }); }
php
public function listPointsToday(Metric $metric, $hours = 12) { $dateTime = $this->dates->make(); $pointKey = $dateTime->format('Y-m-d H:00'); $points = $this->repository->getPointsSinceHour($metric, $hours)->pluck('value', 'key'); for ($i = 0; $i < $hours; $i++) { if (!$points->has($pointKey)) { $points->put($pointKey, $metric->default_value); } $pointKey = $dateTime->sub(new DateInterval('PT1H'))->format('Y-m-d H:00'); } return $points->sortBy(function ($point, $key) { return $key; }); }
[ "public", "function", "listPointsToday", "(", "Metric", "$", "metric", ",", "$", "hours", "=", "12", ")", "{", "$", "dateTime", "=", "$", "this", "->", "dates", "->", "make", "(", ")", ";", "$", "pointKey", "=", "$", "dateTime", "->", "format", "(", "'Y-m-d H:00'", ")", ";", "$", "points", "=", "$", "this", "->", "repository", "->", "getPointsSinceHour", "(", "$", "metric", ",", "$", "hours", ")", "->", "pluck", "(", "'value'", ",", "'key'", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "hours", ";", "$", "i", "++", ")", "{", "if", "(", "!", "$", "points", "->", "has", "(", "$", "pointKey", ")", ")", "{", "$", "points", "->", "put", "(", "$", "pointKey", ",", "$", "metric", "->", "default_value", ")", ";", "}", "$", "pointKey", "=", "$", "dateTime", "->", "sub", "(", "new", "DateInterval", "(", "'PT1H'", ")", ")", "->", "format", "(", "'Y-m-d H:00'", ")", ";", "}", "return", "$", "points", "->", "sortBy", "(", "function", "(", "$", "point", ",", "$", "key", ")", "{", "return", "$", "key", ";", "}", ")", ";", "}" ]
Returns all points as an array, by x hours. @param \CachetHQ\Cachet\Models\Metric $metric @param int $hours @return array
[ "Returns", "all", "points", "as", "an", "array", "by", "x", "hours", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Repositories/Metric/MetricRepository.php#L95-L112
220,828
CachetHQ/Cachet
app/Http/Middleware/Throttler.php
Throttler.getHeaders
protected function getHeaders(string $key, int $limit, int $after = null, array $merge = []) { $remaining = $after === null ? $this->limiter->retriesLeft($key, $limit) : 0; $headers = ['X-RateLimit-Limit' => $limit, 'X-RateLimit-Remaining' => $remaining]; return array_merge($headers, $merge); }
php
protected function getHeaders(string $key, int $limit, int $after = null, array $merge = []) { $remaining = $after === null ? $this->limiter->retriesLeft($key, $limit) : 0; $headers = ['X-RateLimit-Limit' => $limit, 'X-RateLimit-Remaining' => $remaining]; return array_merge($headers, $merge); }
[ "protected", "function", "getHeaders", "(", "string", "$", "key", ",", "int", "$", "limit", ",", "int", "$", "after", "=", "null", ",", "array", "$", "merge", "=", "[", "]", ")", "{", "$", "remaining", "=", "$", "after", "===", "null", "?", "$", "this", "->", "limiter", "->", "retriesLeft", "(", "$", "key", ",", "$", "limit", ")", ":", "0", ";", "$", "headers", "=", "[", "'X-RateLimit-Limit'", "=>", "$", "limit", ",", "'X-RateLimit-Remaining'", "=>", "$", "remaining", "]", ";", "return", "array_merge", "(", "$", "headers", ",", "$", "merge", ")", ";", "}" ]
Get the limit header information. @param string $key @param int $limit @param int|null $after @param array $merge @return array
[ "Get", "the", "limit", "header", "information", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Middleware/Throttler.php#L118-L124
220,829
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ComponentGroupController.php
ComponentGroupController.showComponentGroups
public function showComponentGroups() { $this->subMenu['groups']['active'] = true; return View::make('dashboard.components.groups.index') ->withPageTitle(trans_choice('dashboard.components.groups.groups', 2).' - '.trans('dashboard.dashboard')) ->withGroups(ComponentGroup::orderBy('order')->get()) ->withSubMenu($this->subMenu); }
php
public function showComponentGroups() { $this->subMenu['groups']['active'] = true; return View::make('dashboard.components.groups.index') ->withPageTitle(trans_choice('dashboard.components.groups.groups', 2).' - '.trans('dashboard.dashboard')) ->withGroups(ComponentGroup::orderBy('order')->get()) ->withSubMenu($this->subMenu); }
[ "public", "function", "showComponentGroups", "(", ")", "{", "$", "this", "->", "subMenu", "[", "'groups'", "]", "[", "'active'", "]", "=", "true", ";", "return", "View", "::", "make", "(", "'dashboard.components.groups.index'", ")", "->", "withPageTitle", "(", "trans_choice", "(", "'dashboard.components.groups.groups'", ",", "2", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withGroups", "(", "ComponentGroup", "::", "orderBy", "(", "'order'", ")", "->", "get", "(", ")", ")", "->", "withSubMenu", "(", "$", "this", "->", "subMenu", ")", ";", "}" ]
Shows the component groups view. @return \Illuminate\View\View
[ "Shows", "the", "component", "groups", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ComponentGroupController.php#L71-L79
220,830
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ComponentGroupController.php
ComponentGroupController.deleteComponentGroupAction
public function deleteComponentGroupAction(ComponentGroup $group) { execute(new RemoveComponentGroupCommand($group)); return cachet_redirect('dashboard.components.groups') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success'))); }
php
public function deleteComponentGroupAction(ComponentGroup $group) { execute(new RemoveComponentGroupCommand($group)); return cachet_redirect('dashboard.components.groups') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success'))); }
[ "public", "function", "deleteComponentGroupAction", "(", "ComponentGroup", "$", "group", ")", "{", "execute", "(", "new", "RemoveComponentGroupCommand", "(", "$", "group", ")", ")", ";", "return", "cachet_redirect", "(", "'dashboard.components.groups'", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.components.delete.success'", ")", ")", ")", ";", "}" ]
Deletes a given component group. @param \CachetHQ\Cachet\Models\ComponentGroup $group @return \Illuminate\Http\RedirectResponse
[ "Deletes", "a", "given", "component", "group", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ComponentGroupController.php#L88-L94
220,831
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ComponentGroupController.php
ComponentGroupController.showEditComponentGroup
public function showEditComponentGroup(ComponentGroup $group) { return View::make('dashboard.components.groups.edit') ->withPageTitle(trans('dashboard.components.groups.edit.title').' - '.trans('dashboard.dashboard')) ->withGroup($group); }
php
public function showEditComponentGroup(ComponentGroup $group) { return View::make('dashboard.components.groups.edit') ->withPageTitle(trans('dashboard.components.groups.edit.title').' - '.trans('dashboard.dashboard')) ->withGroup($group); }
[ "public", "function", "showEditComponentGroup", "(", "ComponentGroup", "$", "group", ")", "{", "return", "View", "::", "make", "(", "'dashboard.components.groups.edit'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.components.groups.edit.title'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withGroup", "(", "$", "group", ")", ";", "}" ]
Shows the edit component group view. @param \CachetHQ\Cachet\Models\ComponentGroup $group @return \Illuminate\View\View
[ "Shows", "the", "edit", "component", "group", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ComponentGroupController.php#L114-L119
220,832
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ComponentGroupController.php
ComponentGroupController.updateComponentGroupAction
public function updateComponentGroupAction(ComponentGroup $group) { try { $group = execute(new UpdateComponentGroupCommand( $group, Binput::get('name'), $group->order, Binput::get('collapsed'), Binput::get('visible') )); } catch (ValidationException $e) { return cachet_redirect('dashboard.components.groups.edit', [$group->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.edit.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.components.groups.edit', [$group->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.edit.success'))); }
php
public function updateComponentGroupAction(ComponentGroup $group) { try { $group = execute(new UpdateComponentGroupCommand( $group, Binput::get('name'), $group->order, Binput::get('collapsed'), Binput::get('visible') )); } catch (ValidationException $e) { return cachet_redirect('dashboard.components.groups.edit', [$group->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.edit.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.components.groups.edit', [$group->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.edit.success'))); }
[ "public", "function", "updateComponentGroupAction", "(", "ComponentGroup", "$", "group", ")", "{", "try", "{", "$", "group", "=", "execute", "(", "new", "UpdateComponentGroupCommand", "(", "$", "group", ",", "Binput", "::", "get", "(", "'name'", ")", ",", "$", "group", "->", "order", ",", "Binput", "::", "get", "(", "'collapsed'", ")", ",", "Binput", "::", "get", "(", "'visible'", ")", ")", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "return", "cachet_redirect", "(", "'dashboard.components.groups.edit'", ",", "[", "$", "group", "->", "id", "]", ")", "->", "withInput", "(", "Binput", "::", "all", "(", ")", ")", "->", "withTitle", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.whoops'", ")", ",", "trans", "(", "'dashboard.components.groups.edit.failure'", ")", ")", ")", "->", "withErrors", "(", "$", "e", "->", "getMessageBag", "(", ")", ")", ";", "}", "return", "cachet_redirect", "(", "'dashboard.components.groups.edit'", ",", "[", "$", "group", "->", "id", "]", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.components.groups.edit.success'", ")", ")", ")", ";", "}" ]
Updates a component group. @param \CachetHQ\Cachet\Models\ComponentGroup $group @return \Illuminate\Http\RedirectResponse
[ "Updates", "a", "component", "group", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ComponentGroupController.php#L153-L172
220,833
CachetHQ/Cachet
app/Http/Controllers/Dashboard/IncidentController.php
IncidentController.showIncidents
public function showIncidents() { $incidents = Incident::with('user')->orderBy('created_at', 'desc')->get(); return View::make('dashboard.incidents.index') ->withPageTitle(trans('dashboard.incidents.incidents').' - '.trans('dashboard.dashboard')) ->withIncidents($incidents); }
php
public function showIncidents() { $incidents = Incident::with('user')->orderBy('created_at', 'desc')->get(); return View::make('dashboard.incidents.index') ->withPageTitle(trans('dashboard.incidents.incidents').' - '.trans('dashboard.dashboard')) ->withIncidents($incidents); }
[ "public", "function", "showIncidents", "(", ")", "{", "$", "incidents", "=", "Incident", "::", "with", "(", "'user'", ")", "->", "orderBy", "(", "'created_at'", ",", "'desc'", ")", "->", "get", "(", ")", ";", "return", "View", "::", "make", "(", "'dashboard.incidents.index'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.incidents.incidents'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withIncidents", "(", "$", "incidents", ")", ";", "}" ]
Shows the incidents view. @return \Illuminate\View\View
[ "Shows", "the", "incidents", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/IncidentController.php#L76-L83
220,834
CachetHQ/Cachet
app/Http/Controllers/Dashboard/IncidentController.php
IncidentController.showAddIncident
public function showAddIncident() { return View::make('dashboard.incidents.add') ->withPageTitle(trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard')) ->withComponentsInGroups(ComponentGroup::with('components')->get()) ->withComponentsOutGroups(Component::where('group_id', '=', 0)->get()) ->withNotificationsEnabled($this->system->canNotifySubscribers()) ->withIncidentTemplates(IncidentTemplate::all()); }
php
public function showAddIncident() { return View::make('dashboard.incidents.add') ->withPageTitle(trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard')) ->withComponentsInGroups(ComponentGroup::with('components')->get()) ->withComponentsOutGroups(Component::where('group_id', '=', 0)->get()) ->withNotificationsEnabled($this->system->canNotifySubscribers()) ->withIncidentTemplates(IncidentTemplate::all()); }
[ "public", "function", "showAddIncident", "(", ")", "{", "return", "View", "::", "make", "(", "'dashboard.incidents.add'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.incidents.add.title'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withComponentsInGroups", "(", "ComponentGroup", "::", "with", "(", "'components'", ")", "->", "get", "(", ")", ")", "->", "withComponentsOutGroups", "(", "Component", "::", "where", "(", "'group_id'", ",", "'='", ",", "0", ")", "->", "get", "(", ")", ")", "->", "withNotificationsEnabled", "(", "$", "this", "->", "system", "->", "canNotifySubscribers", "(", ")", ")", "->", "withIncidentTemplates", "(", "IncidentTemplate", "::", "all", "(", ")", ")", ";", "}" ]
Shows the add incident view. @return \Illuminate\View\View
[ "Shows", "the", "add", "incident", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/IncidentController.php#L90-L98
220,835
CachetHQ/Cachet
app/Http/Controllers/Dashboard/IncidentController.php
IncidentController.createIncidentAction
public function createIncidentAction() { try { $incident = execute(new CreateIncidentCommand( Binput::get('name'), Binput::get('status'), Binput::get('message', null, false, false), Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', false), Binput::get('stickied', false), Binput::get('occurred_at'), null, [], ['seo' => Binput::get('seo', [])] )); } catch (ValidationException $e) { return cachet_redirect('dashboard.incidents.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.incidents') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success'))); }
php
public function createIncidentAction() { try { $incident = execute(new CreateIncidentCommand( Binput::get('name'), Binput::get('status'), Binput::get('message', null, false, false), Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', false), Binput::get('stickied', false), Binput::get('occurred_at'), null, [], ['seo' => Binput::get('seo', [])] )); } catch (ValidationException $e) { return cachet_redirect('dashboard.incidents.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.incidents') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success'))); }
[ "public", "function", "createIncidentAction", "(", ")", "{", "try", "{", "$", "incident", "=", "execute", "(", "new", "CreateIncidentCommand", "(", "Binput", "::", "get", "(", "'name'", ")", ",", "Binput", "::", "get", "(", "'status'", ")", ",", "Binput", "::", "get", "(", "'message'", ",", "null", ",", "false", ",", "false", ")", ",", "Binput", "::", "get", "(", "'visible'", ",", "true", ")", ",", "Binput", "::", "get", "(", "'component_id'", ")", ",", "Binput", "::", "get", "(", "'component_status'", ")", ",", "Binput", "::", "get", "(", "'notify'", ",", "false", ")", ",", "Binput", "::", "get", "(", "'stickied'", ",", "false", ")", ",", "Binput", "::", "get", "(", "'occurred_at'", ")", ",", "null", ",", "[", "]", ",", "[", "'seo'", "=>", "Binput", "::", "get", "(", "'seo'", ",", "[", "]", ")", "]", ")", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "return", "cachet_redirect", "(", "'dashboard.incidents.create'", ")", "->", "withInput", "(", "Binput", "::", "all", "(", ")", ")", "->", "withTitle", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.whoops'", ")", ",", "trans", "(", "'dashboard.incidents.add.failure'", ")", ")", ")", "->", "withErrors", "(", "$", "e", "->", "getMessageBag", "(", ")", ")", ";", "}", "return", "cachet_redirect", "(", "'dashboard.incidents'", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.incidents.add.success'", ")", ")", ")", ";", "}" ]
Creates a new incident. @return \Illuminate\Http\RedirectResponse
[ "Creates", "a", "new", "incident", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/IncidentController.php#L117-L143
220,836
CachetHQ/Cachet
app/Http/Controllers/Dashboard/IncidentController.php
IncidentController.showEditTemplateAction
public function showEditTemplateAction(IncidentTemplate $template) { return View::make('dashboard.templates.edit') ->withPageTitle(trans('dashboard.incidents.templates.edit.title').' - '.trans('dashboard.dashboard')) ->withTemplate($template); }
php
public function showEditTemplateAction(IncidentTemplate $template) { return View::make('dashboard.templates.edit') ->withPageTitle(trans('dashboard.incidents.templates.edit.title').' - '.trans('dashboard.dashboard')) ->withTemplate($template); }
[ "public", "function", "showEditTemplateAction", "(", "IncidentTemplate", "$", "template", ")", "{", "return", "View", "::", "make", "(", "'dashboard.templates.edit'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.incidents.templates.edit.title'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withTemplate", "(", "$", "template", ")", ";", "}" ]
Shows the edit incident template view. @param \CachetHQ\Cachet\Models\IncidentTemplate $template @return \Illuminate\View\View
[ "Shows", "the", "edit", "incident", "template", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/IncidentController.php#L163-L168
220,837
CachetHQ/Cachet
app/Http/Controllers/Dashboard/IncidentController.php
IncidentController.deleteTemplateAction
public function deleteTemplateAction(IncidentTemplate $template) { $template->delete(); return cachet_redirect('dashboard.templates') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.delete.success'))); }
php
public function deleteTemplateAction(IncidentTemplate $template) { $template->delete(); return cachet_redirect('dashboard.templates') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.delete.success'))); }
[ "public", "function", "deleteTemplateAction", "(", "IncidentTemplate", "$", "template", ")", "{", "$", "template", "->", "delete", "(", ")", ";", "return", "cachet_redirect", "(", "'dashboard.templates'", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.incidents.templates.delete.success'", ")", ")", ")", ";", "}" ]
Deletes an incident template. @param \CachetHQ\Cachet\Models\IncidentTemplate $template @return \Illuminate\Http\RedirectResponse
[ "Deletes", "an", "incident", "template", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/IncidentController.php#L177-L183
220,838
CachetHQ/Cachet
app/Http/Controllers/Dashboard/IncidentController.php
IncidentController.createIncidentTemplateAction
public function createIncidentTemplateAction() { try { IncidentTemplate::create([ 'name' => Binput::get('name'), 'template' => Binput::get('template', null, false, false), ]); } catch (ValidationException $e) { return cachet_redirect('dashboard.templates.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.add.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.templates') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.add.success'))); }
php
public function createIncidentTemplateAction() { try { IncidentTemplate::create([ 'name' => Binput::get('name'), 'template' => Binput::get('template', null, false, false), ]); } catch (ValidationException $e) { return cachet_redirect('dashboard.templates.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.add.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.templates') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.add.success'))); }
[ "public", "function", "createIncidentTemplateAction", "(", ")", "{", "try", "{", "IncidentTemplate", "::", "create", "(", "[", "'name'", "=>", "Binput", "::", "get", "(", "'name'", ")", ",", "'template'", "=>", "Binput", "::", "get", "(", "'template'", ",", "null", ",", "false", ",", "false", ")", ",", "]", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "return", "cachet_redirect", "(", "'dashboard.templates.create'", ")", "->", "withInput", "(", "Binput", "::", "all", "(", ")", ")", "->", "withTitle", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.whoops'", ")", ",", "trans", "(", "'dashboard.incidents.templates.add.failure'", ")", ")", ")", "->", "withErrors", "(", "$", "e", "->", "getMessageBag", "(", ")", ")", ";", "}", "return", "cachet_redirect", "(", "'dashboard.templates'", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.incidents.templates.add.success'", ")", ")", ")", ";", "}" ]
Creates a new incident template. @return \Illuminate\Http\RedirectResponse
[ "Creates", "a", "new", "incident", "template", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/IncidentController.php#L190-L206
220,839
CachetHQ/Cachet
app/Http/Controllers/Dashboard/IncidentController.php
IncidentController.deleteIncidentAction
public function deleteIncidentAction(Incident $incident) { execute(new RemoveIncidentCommand($incident)); return cachet_redirect('dashboard.incidents') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success'))); }
php
public function deleteIncidentAction(Incident $incident) { execute(new RemoveIncidentCommand($incident)); return cachet_redirect('dashboard.incidents') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success'))); }
[ "public", "function", "deleteIncidentAction", "(", "Incident", "$", "incident", ")", "{", "execute", "(", "new", "RemoveIncidentCommand", "(", "$", "incident", ")", ")", ";", "return", "cachet_redirect", "(", "'dashboard.incidents'", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.incidents.delete.success'", ")", ")", ")", ";", "}" ]
Deletes a given incident. @param \CachetHQ\Cachet\Models\Incident $incident @return \Illuminate\Http\RedirectResponse
[ "Deletes", "a", "given", "incident", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/IncidentController.php#L215-L221
220,840
CachetHQ/Cachet
app/Http/Controllers/Dashboard/IncidentController.php
IncidentController.editIncidentAction
public function editIncidentAction(Incident $incident) { try { $incident = execute(new UpdateIncidentCommand( $incident, Binput::get('name'), Binput::get('status'), Binput::get('message'), Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', true), Binput::get('stickied', false), Binput::get('occurred_at'), null, [], ['seo' => Binput::get('seo', [])] )); } catch (ValidationException $e) { return cachet_redirect('dashboard.incidents.edit', ['id' => $incident->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure'))) ->withErrors($e->getMessageBag()); } if ($incident->component) { $incident->component->update(['status' => Binput::get('component_status')]); } return cachet_redirect('dashboard.incidents.edit', ['id' => $incident->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.edit.success'))); }
php
public function editIncidentAction(Incident $incident) { try { $incident = execute(new UpdateIncidentCommand( $incident, Binput::get('name'), Binput::get('status'), Binput::get('message'), Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', true), Binput::get('stickied', false), Binput::get('occurred_at'), null, [], ['seo' => Binput::get('seo', [])] )); } catch (ValidationException $e) { return cachet_redirect('dashboard.incidents.edit', ['id' => $incident->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure'))) ->withErrors($e->getMessageBag()); } if ($incident->component) { $incident->component->update(['status' => Binput::get('component_status')]); } return cachet_redirect('dashboard.incidents.edit', ['id' => $incident->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.edit.success'))); }
[ "public", "function", "editIncidentAction", "(", "Incident", "$", "incident", ")", "{", "try", "{", "$", "incident", "=", "execute", "(", "new", "UpdateIncidentCommand", "(", "$", "incident", ",", "Binput", "::", "get", "(", "'name'", ")", ",", "Binput", "::", "get", "(", "'status'", ")", ",", "Binput", "::", "get", "(", "'message'", ")", ",", "Binput", "::", "get", "(", "'visible'", ",", "true", ")", ",", "Binput", "::", "get", "(", "'component_id'", ")", ",", "Binput", "::", "get", "(", "'component_status'", ")", ",", "Binput", "::", "get", "(", "'notify'", ",", "true", ")", ",", "Binput", "::", "get", "(", "'stickied'", ",", "false", ")", ",", "Binput", "::", "get", "(", "'occurred_at'", ")", ",", "null", ",", "[", "]", ",", "[", "'seo'", "=>", "Binput", "::", "get", "(", "'seo'", ",", "[", "]", ")", "]", ")", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "return", "cachet_redirect", "(", "'dashboard.incidents.edit'", ",", "[", "'id'", "=>", "$", "incident", "->", "id", "]", ")", "->", "withInput", "(", "Binput", "::", "all", "(", ")", ")", "->", "withTitle", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.whoops'", ")", ",", "trans", "(", "'dashboard.incidents.templates.edit.failure'", ")", ")", ")", "->", "withErrors", "(", "$", "e", "->", "getMessageBag", "(", ")", ")", ";", "}", "if", "(", "$", "incident", "->", "component", ")", "{", "$", "incident", "->", "component", "->", "update", "(", "[", "'status'", "=>", "Binput", "::", "get", "(", "'component_status'", ")", "]", ")", ";", "}", "return", "cachet_redirect", "(", "'dashboard.incidents.edit'", ",", "[", "'id'", "=>", "$", "incident", "->", "id", "]", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.incidents.edit.success'", ")", ")", ")", ";", "}" ]
Edit an incident. @param \CachetHQ\Cachet\Models\Incident $incident @return \Illuminate\Http\RedirectResponse
[ "Edit", "an", "incident", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/IncidentController.php#L247-L278
220,841
CachetHQ/Cachet
app/Http/Controllers/Dashboard/IncidentController.php
IncidentController.editTemplateAction
public function editTemplateAction(IncidentTemplate $template) { try { $template->update(Binput::get('template')); } catch (ValidationException $e) { return cachet_redirect('dashboard.templates.edit', ['id' => $template->id]) ->withUpdatedTemplate($template) ->withTemplateErrors($e->getMessageBag()->getErrors()); } return cachet_redirect('dashboard.templates.edit', ['id' => $template->id]) ->withUpdatedTemplate($template); }
php
public function editTemplateAction(IncidentTemplate $template) { try { $template->update(Binput::get('template')); } catch (ValidationException $e) { return cachet_redirect('dashboard.templates.edit', ['id' => $template->id]) ->withUpdatedTemplate($template) ->withTemplateErrors($e->getMessageBag()->getErrors()); } return cachet_redirect('dashboard.templates.edit', ['id' => $template->id]) ->withUpdatedTemplate($template); }
[ "public", "function", "editTemplateAction", "(", "IncidentTemplate", "$", "template", ")", "{", "try", "{", "$", "template", "->", "update", "(", "Binput", "::", "get", "(", "'template'", ")", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "return", "cachet_redirect", "(", "'dashboard.templates.edit'", ",", "[", "'id'", "=>", "$", "template", "->", "id", "]", ")", "->", "withUpdatedTemplate", "(", "$", "template", ")", "->", "withTemplateErrors", "(", "$", "e", "->", "getMessageBag", "(", ")", "->", "getErrors", "(", ")", ")", ";", "}", "return", "cachet_redirect", "(", "'dashboard.templates.edit'", ",", "[", "'id'", "=>", "$", "template", "->", "id", "]", ")", "->", "withUpdatedTemplate", "(", "$", "template", ")", ";", "}" ]
Edit an incident template. @param \CachetHQ\Cachet\Models\IncidentTemplate $template @return \Illuminate\Http\RedirectResponse
[ "Edit", "an", "incident", "template", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/IncidentController.php#L287-L299
220,842
CachetHQ/Cachet
app/Http/Controllers/Dashboard/SettingsController.php
SettingsController.showSetupView
public function showSetupView() { $this->subMenu['setup']['active'] = true; Session::flash('redirect_to', $this->subMenu['setup']['url']); return View::make('dashboard.settings.app-setup') ->withPageTitle(trans('dashboard.settings.app-setup.app-setup').' - '.trans('dashboard.dashboard')) ->withSubMenu($this->subMenu) ->withRawAppAbout(Config::get('setting.app_about')); }
php
public function showSetupView() { $this->subMenu['setup']['active'] = true; Session::flash('redirect_to', $this->subMenu['setup']['url']); return View::make('dashboard.settings.app-setup') ->withPageTitle(trans('dashboard.settings.app-setup.app-setup').' - '.trans('dashboard.dashboard')) ->withSubMenu($this->subMenu) ->withRawAppAbout(Config::get('setting.app_about')); }
[ "public", "function", "showSetupView", "(", ")", "{", "$", "this", "->", "subMenu", "[", "'setup'", "]", "[", "'active'", "]", "=", "true", ";", "Session", "::", "flash", "(", "'redirect_to'", ",", "$", "this", "->", "subMenu", "[", "'setup'", "]", "[", "'url'", "]", ")", ";", "return", "View", "::", "make", "(", "'dashboard.settings.app-setup'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.settings.app-setup.app-setup'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withSubMenu", "(", "$", "this", "->", "subMenu", ")", "->", "withRawAppAbout", "(", "Config", "::", "get", "(", "'setting.app_about'", ")", ")", ";", "}" ]
Shows the settings setup view. @return \Illuminate\View\View
[ "Shows", "the", "settings", "setup", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/SettingsController.php#L129-L139
220,843
CachetHQ/Cachet
app/Http/Controllers/Dashboard/SettingsController.php
SettingsController.showSecurityView
public function showSecurityView() { $this->subMenu['security']['active'] = true; $unsecureUsers = User::whereNull('google_2fa_secret')->orWhere('google_2fa_secret', '=', '')->get(); Session::flash('redirect_to', $this->subMenu['security']['url']); return View::make('dashboard.settings.security') ->withPageTitle(trans('dashboard.settings.security.security').' - '.trans('dashboard.dashboard')) ->withSubMenu($this->subMenu) ->withUnsecureUsers($unsecureUsers); }
php
public function showSecurityView() { $this->subMenu['security']['active'] = true; $unsecureUsers = User::whereNull('google_2fa_secret')->orWhere('google_2fa_secret', '=', '')->get(); Session::flash('redirect_to', $this->subMenu['security']['url']); return View::make('dashboard.settings.security') ->withPageTitle(trans('dashboard.settings.security.security').' - '.trans('dashboard.dashboard')) ->withSubMenu($this->subMenu) ->withUnsecureUsers($unsecureUsers); }
[ "public", "function", "showSecurityView", "(", ")", "{", "$", "this", "->", "subMenu", "[", "'security'", "]", "[", "'active'", "]", "=", "true", ";", "$", "unsecureUsers", "=", "User", "::", "whereNull", "(", "'google_2fa_secret'", ")", "->", "orWhere", "(", "'google_2fa_secret'", ",", "'='", ",", "''", ")", "->", "get", "(", ")", ";", "Session", "::", "flash", "(", "'redirect_to'", ",", "$", "this", "->", "subMenu", "[", "'security'", "]", "[", "'url'", "]", ")", ";", "return", "View", "::", "make", "(", "'dashboard.settings.security'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.settings.security.security'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withSubMenu", "(", "$", "this", "->", "subMenu", ")", "->", "withUnsecureUsers", "(", "$", "unsecureUsers", ")", ";", "}" ]
Shows the settings security view. @return \Illuminate\View\View
[ "Shows", "the", "settings", "security", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/SettingsController.php#L210-L222
220,844
CachetHQ/Cachet
app/Http/Controllers/Dashboard/SettingsController.php
SettingsController.showStylesheetView
public function showStylesheetView() { $this->subMenu['stylesheet']['active'] = true; Session::flash('redirect_to', $this->subMenu['stylesheet']['url']); return View::make('dashboard.settings.stylesheet') ->withPageTitle(trans('dashboard.settings.stylesheet.stylesheet').' - '.trans('dashboard.dashboard')) ->withSubMenu($this->subMenu); }
php
public function showStylesheetView() { $this->subMenu['stylesheet']['active'] = true; Session::flash('redirect_to', $this->subMenu['stylesheet']['url']); return View::make('dashboard.settings.stylesheet') ->withPageTitle(trans('dashboard.settings.stylesheet.stylesheet').' - '.trans('dashboard.dashboard')) ->withSubMenu($this->subMenu); }
[ "public", "function", "showStylesheetView", "(", ")", "{", "$", "this", "->", "subMenu", "[", "'stylesheet'", "]", "[", "'active'", "]", "=", "true", ";", "Session", "::", "flash", "(", "'redirect_to'", ",", "$", "this", "->", "subMenu", "[", "'stylesheet'", "]", "[", "'url'", "]", ")", ";", "return", "View", "::", "make", "(", "'dashboard.settings.stylesheet'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.settings.stylesheet.stylesheet'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withSubMenu", "(", "$", "this", "->", "subMenu", ")", ";", "}" ]
Shows the settings stylesheet view. @return \Illuminate\View\View
[ "Shows", "the", "settings", "stylesheet", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/SettingsController.php#L229-L238
220,845
CachetHQ/Cachet
app/Http/Controllers/Dashboard/SettingsController.php
SettingsController.showCreditsView
public function showCreditsView() { $this->subMenu['credits']['active'] = true; $credits = app(Credits::class)->latest(); $backers = $credits['backers']; $contributors = $credits['contributors']; shuffle($backers); shuffle($contributors); return View::make('dashboard.settings.credits') ->withPageTitle(trans('dashboard.settings.credits.credits').' - '.trans('dashboard.dashboard')) ->withBackers($backers) ->withContributors($contributors) ->withSubMenu($this->subMenu); }
php
public function showCreditsView() { $this->subMenu['credits']['active'] = true; $credits = app(Credits::class)->latest(); $backers = $credits['backers']; $contributors = $credits['contributors']; shuffle($backers); shuffle($contributors); return View::make('dashboard.settings.credits') ->withPageTitle(trans('dashboard.settings.credits.credits').' - '.trans('dashboard.dashboard')) ->withBackers($backers) ->withContributors($contributors) ->withSubMenu($this->subMenu); }
[ "public", "function", "showCreditsView", "(", ")", "{", "$", "this", "->", "subMenu", "[", "'credits'", "]", "[", "'active'", "]", "=", "true", ";", "$", "credits", "=", "app", "(", "Credits", "::", "class", ")", "->", "latest", "(", ")", ";", "$", "backers", "=", "$", "credits", "[", "'backers'", "]", ";", "$", "contributors", "=", "$", "credits", "[", "'contributors'", "]", ";", "shuffle", "(", "$", "backers", ")", ";", "shuffle", "(", "$", "contributors", ")", ";", "return", "View", "::", "make", "(", "'dashboard.settings.credits'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.settings.credits.credits'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withBackers", "(", "$", "backers", ")", "->", "withContributors", "(", "$", "contributors", ")", "->", "withSubMenu", "(", "$", "this", "->", "subMenu", ")", ";", "}" ]
Show the credits view. @return \Illuminate\View\View
[ "Show", "the", "credits", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/SettingsController.php#L245-L262
220,846
CachetHQ/Cachet
app/Http/Controllers/Dashboard/SettingsController.php
SettingsController.showLogView
public function showLogView() { $this->subMenu['log']['active'] = true; $log = Log::getLogger(); $logContents = ''; collect($log->getHandlers())->reject(function ($handler) { return $handler instanceof SyslogHandler; })->each(function ($handler) use (&$logContents, $log) { if (file_exists($path = $log->getHandlers()[0]->getUrl())) { $logContents = file_get_contents($path); } }); return View::make('dashboard.settings.log')->withLog($logContents)->withSubMenu($this->subMenu); }
php
public function showLogView() { $this->subMenu['log']['active'] = true; $log = Log::getLogger(); $logContents = ''; collect($log->getHandlers())->reject(function ($handler) { return $handler instanceof SyslogHandler; })->each(function ($handler) use (&$logContents, $log) { if (file_exists($path = $log->getHandlers()[0]->getUrl())) { $logContents = file_get_contents($path); } }); return View::make('dashboard.settings.log')->withLog($logContents)->withSubMenu($this->subMenu); }
[ "public", "function", "showLogView", "(", ")", "{", "$", "this", "->", "subMenu", "[", "'log'", "]", "[", "'active'", "]", "=", "true", ";", "$", "log", "=", "Log", "::", "getLogger", "(", ")", ";", "$", "logContents", "=", "''", ";", "collect", "(", "$", "log", "->", "getHandlers", "(", ")", ")", "->", "reject", "(", "function", "(", "$", "handler", ")", "{", "return", "$", "handler", "instanceof", "SyslogHandler", ";", "}", ")", "->", "each", "(", "function", "(", "$", "handler", ")", "use", "(", "&", "$", "logContents", ",", "$", "log", ")", "{", "if", "(", "file_exists", "(", "$", "path", "=", "$", "log", "->", "getHandlers", "(", ")", "[", "0", "]", "->", "getUrl", "(", ")", ")", ")", "{", "$", "logContents", "=", "file_get_contents", "(", "$", "path", ")", ";", "}", "}", ")", ";", "return", "View", "::", "make", "(", "'dashboard.settings.log'", ")", "->", "withLog", "(", "$", "logContents", ")", "->", "withSubMenu", "(", "$", "this", "->", "subMenu", ")", ";", "}" ]
Show the most recent log. @return \Illuminate\View\View
[ "Show", "the", "most", "recent", "log", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/SettingsController.php#L269-L286
220,847
CachetHQ/Cachet
app/Http/Controllers/Dashboard/SettingsController.php
SettingsController.postMail
public function postMail() { $config = Binput::get('config'); execute(new UpdateConfigCommand($config)); return cachet_redirect('dashboard.settings.mail') ->withInput(Binput::all()) ->withSuccess(trans('dashboard.notifications.awesome')); }
php
public function postMail() { $config = Binput::get('config'); execute(new UpdateConfigCommand($config)); return cachet_redirect('dashboard.settings.mail') ->withInput(Binput::all()) ->withSuccess(trans('dashboard.notifications.awesome')); }
[ "public", "function", "postMail", "(", ")", "{", "$", "config", "=", "Binput", "::", "get", "(", "'config'", ")", ";", "execute", "(", "new", "UpdateConfigCommand", "(", "$", "config", ")", ")", ";", "return", "cachet_redirect", "(", "'dashboard.settings.mail'", ")", "->", "withInput", "(", "Binput", "::", "all", "(", ")", ")", "->", "withSuccess", "(", "trans", "(", "'dashboard.notifications.awesome'", ")", ")", ";", "}" ]
Handle updating of the settings. @return \Illuminate\Http\RedirectResponse
[ "Handle", "updating", "of", "the", "settings", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/SettingsController.php#L318-L327
220,848
CachetHQ/Cachet
app/Http/Controllers/Dashboard/SettingsController.php
SettingsController.postSettings
public function postSettings() { $setting = app(Repository::class); if (Binput::get('remove_banner') === '1') { $setting->set('app_banner', null); } $parameters = Binput::all(); if (isset($parameters['header'])) { if ($header = Binput::get('header', null, false, false)) { $setting->set('header', $header); } else { $setting->delete('header'); } } if (isset($parameters['footer'])) { if ($footer = Binput::get('footer', null, false, false)) { $setting->set('footer', $footer); } else { $setting->delete('footer'); } } if (isset($parameters['stylesheet'])) { if ($stylesheet = Binput::get('stylesheet', null, false, false)) { $setting->set('stylesheet', $stylesheet); } else { $setting->delete('stylesheet'); } } if (Binput::hasFile('app_banner')) { $this->handleUpdateBanner($setting); } $excludedParams = [ '_token', 'app_banner', 'remove_banner', 'header', 'footer', 'stylesheet', ]; try { foreach (Binput::except($excludedParams) as $settingName => $settingValue) { if ($settingName === 'app_analytics_pi_url') { $settingValue = rtrim($settingValue, '/'); } $setting->set($settingName, $settingValue); } } catch (Exception $e) { return Redirect::back()->withErrors(trans('dashboard.settings.edit.failure')); } if (Binput::has('app_locale')) { Lang::setLocale(Binput::get('app_locale')); } if (Binput::has('always_authenticate')) { Artisan::call('route:clear'); } return Redirect::back()->withSuccess(trans('dashboard.settings.edit.success')); }
php
public function postSettings() { $setting = app(Repository::class); if (Binput::get('remove_banner') === '1') { $setting->set('app_banner', null); } $parameters = Binput::all(); if (isset($parameters['header'])) { if ($header = Binput::get('header', null, false, false)) { $setting->set('header', $header); } else { $setting->delete('header'); } } if (isset($parameters['footer'])) { if ($footer = Binput::get('footer', null, false, false)) { $setting->set('footer', $footer); } else { $setting->delete('footer'); } } if (isset($parameters['stylesheet'])) { if ($stylesheet = Binput::get('stylesheet', null, false, false)) { $setting->set('stylesheet', $stylesheet); } else { $setting->delete('stylesheet'); } } if (Binput::hasFile('app_banner')) { $this->handleUpdateBanner($setting); } $excludedParams = [ '_token', 'app_banner', 'remove_banner', 'header', 'footer', 'stylesheet', ]; try { foreach (Binput::except($excludedParams) as $settingName => $settingValue) { if ($settingName === 'app_analytics_pi_url') { $settingValue = rtrim($settingValue, '/'); } $setting->set($settingName, $settingValue); } } catch (Exception $e) { return Redirect::back()->withErrors(trans('dashboard.settings.edit.failure')); } if (Binput::has('app_locale')) { Lang::setLocale(Binput::get('app_locale')); } if (Binput::has('always_authenticate')) { Artisan::call('route:clear'); } return Redirect::back()->withSuccess(trans('dashboard.settings.edit.success')); }
[ "public", "function", "postSettings", "(", ")", "{", "$", "setting", "=", "app", "(", "Repository", "::", "class", ")", ";", "if", "(", "Binput", "::", "get", "(", "'remove_banner'", ")", "===", "'1'", ")", "{", "$", "setting", "->", "set", "(", "'app_banner'", ",", "null", ")", ";", "}", "$", "parameters", "=", "Binput", "::", "all", "(", ")", ";", "if", "(", "isset", "(", "$", "parameters", "[", "'header'", "]", ")", ")", "{", "if", "(", "$", "header", "=", "Binput", "::", "get", "(", "'header'", ",", "null", ",", "false", ",", "false", ")", ")", "{", "$", "setting", "->", "set", "(", "'header'", ",", "$", "header", ")", ";", "}", "else", "{", "$", "setting", "->", "delete", "(", "'header'", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "parameters", "[", "'footer'", "]", ")", ")", "{", "if", "(", "$", "footer", "=", "Binput", "::", "get", "(", "'footer'", ",", "null", ",", "false", ",", "false", ")", ")", "{", "$", "setting", "->", "set", "(", "'footer'", ",", "$", "footer", ")", ";", "}", "else", "{", "$", "setting", "->", "delete", "(", "'footer'", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "parameters", "[", "'stylesheet'", "]", ")", ")", "{", "if", "(", "$", "stylesheet", "=", "Binput", "::", "get", "(", "'stylesheet'", ",", "null", ",", "false", ",", "false", ")", ")", "{", "$", "setting", "->", "set", "(", "'stylesheet'", ",", "$", "stylesheet", ")", ";", "}", "else", "{", "$", "setting", "->", "delete", "(", "'stylesheet'", ")", ";", "}", "}", "if", "(", "Binput", "::", "hasFile", "(", "'app_banner'", ")", ")", "{", "$", "this", "->", "handleUpdateBanner", "(", "$", "setting", ")", ";", "}", "$", "excludedParams", "=", "[", "'_token'", ",", "'app_banner'", ",", "'remove_banner'", ",", "'header'", ",", "'footer'", ",", "'stylesheet'", ",", "]", ";", "try", "{", "foreach", "(", "Binput", "::", "except", "(", "$", "excludedParams", ")", "as", "$", "settingName", "=>", "$", "settingValue", ")", "{", "if", "(", "$", "settingName", "===", "'app_analytics_pi_url'", ")", "{", "$", "settingValue", "=", "rtrim", "(", "$", "settingValue", ",", "'/'", ")", ";", "}", "$", "setting", "->", "set", "(", "$", "settingName", ",", "$", "settingValue", ")", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "Redirect", "::", "back", "(", ")", "->", "withErrors", "(", "trans", "(", "'dashboard.settings.edit.failure'", ")", ")", ";", "}", "if", "(", "Binput", "::", "has", "(", "'app_locale'", ")", ")", "{", "Lang", "::", "setLocale", "(", "Binput", "::", "get", "(", "'app_locale'", ")", ")", ";", "}", "if", "(", "Binput", "::", "has", "(", "'always_authenticate'", ")", ")", "{", "Artisan", "::", "call", "(", "'route:clear'", ")", ";", "}", "return", "Redirect", "::", "back", "(", ")", "->", "withSuccess", "(", "trans", "(", "'dashboard.settings.edit.success'", ")", ")", ";", "}" ]
Updates the status page settings. @return \Illuminate\View\View
[ "Updates", "the", "status", "page", "settings", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/SettingsController.php#L334-L402
220,849
CachetHQ/Cachet
app/Http/Controllers/Dashboard/SettingsController.php
SettingsController.handleUpdateBanner
protected function handleUpdateBanner(Repository $setting) { $file = Binput::file('app_banner'); $redirectUrl = $this->subMenu['theme']['url']; // Image Validation. // Image size in bytes. $maxSize = $file->getMaxFilesize(); if ($file->getSize() > $maxSize) { return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.app-setup.too-big', ['size' => $maxSize])); } if (!$file->isValid() || $file->getError()) { return Redirect::to($redirectUrl)->withErrors($file->getErrorMessage()); } if (!Str::startsWith($file->getMimeType(), 'image/')) { return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.app-setup.images-only')); } // Store the banner. $setting->set('app_banner', base64_encode(file_get_contents($file->getRealPath()))); // Store the banner type. $setting->set('app_banner_type', $file->getMimeType()); }
php
protected function handleUpdateBanner(Repository $setting) { $file = Binput::file('app_banner'); $redirectUrl = $this->subMenu['theme']['url']; // Image Validation. // Image size in bytes. $maxSize = $file->getMaxFilesize(); if ($file->getSize() > $maxSize) { return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.app-setup.too-big', ['size' => $maxSize])); } if (!$file->isValid() || $file->getError()) { return Redirect::to($redirectUrl)->withErrors($file->getErrorMessage()); } if (!Str::startsWith($file->getMimeType(), 'image/')) { return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.app-setup.images-only')); } // Store the banner. $setting->set('app_banner', base64_encode(file_get_contents($file->getRealPath()))); // Store the banner type. $setting->set('app_banner_type', $file->getMimeType()); }
[ "protected", "function", "handleUpdateBanner", "(", "Repository", "$", "setting", ")", "{", "$", "file", "=", "Binput", "::", "file", "(", "'app_banner'", ")", ";", "$", "redirectUrl", "=", "$", "this", "->", "subMenu", "[", "'theme'", "]", "[", "'url'", "]", ";", "// Image Validation.", "// Image size in bytes.", "$", "maxSize", "=", "$", "file", "->", "getMaxFilesize", "(", ")", ";", "if", "(", "$", "file", "->", "getSize", "(", ")", ">", "$", "maxSize", ")", "{", "return", "Redirect", "::", "to", "(", "$", "redirectUrl", ")", "->", "withErrors", "(", "trans", "(", "'dashboard.settings.app-setup.too-big'", ",", "[", "'size'", "=>", "$", "maxSize", "]", ")", ")", ";", "}", "if", "(", "!", "$", "file", "->", "isValid", "(", ")", "||", "$", "file", "->", "getError", "(", ")", ")", "{", "return", "Redirect", "::", "to", "(", "$", "redirectUrl", ")", "->", "withErrors", "(", "$", "file", "->", "getErrorMessage", "(", ")", ")", ";", "}", "if", "(", "!", "Str", "::", "startsWith", "(", "$", "file", "->", "getMimeType", "(", ")", ",", "'image/'", ")", ")", "{", "return", "Redirect", "::", "to", "(", "$", "redirectUrl", ")", "->", "withErrors", "(", "trans", "(", "'dashboard.settings.app-setup.images-only'", ")", ")", ";", "}", "// Store the banner.", "$", "setting", "->", "set", "(", "'app_banner'", ",", "base64_encode", "(", "file_get_contents", "(", "$", "file", "->", "getRealPath", "(", ")", ")", ")", ")", ";", "// Store the banner type.", "$", "setting", "->", "set", "(", "'app_banner_type'", ",", "$", "file", "->", "getMimeType", "(", ")", ")", ";", "}" ]
Handle updating of the banner image. @param \CachetHQ\Cachet\Settings\Repository $setting @return void
[ "Handle", "updating", "of", "the", "banner", "image", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/SettingsController.php#L411-L437
220,850
CachetHQ/Cachet
app/Bus/Handlers/Commands/Incident/CreateIncidentCommandHandler.php
CreateIncidentCommandHandler.handle
public function handle(CreateIncidentCommand $command) { $data = [ 'user_id' => $this->auth->user()->id, 'name' => $command->name, 'status' => $command->status, 'visible' => $command->visible, 'stickied' => $command->stickied, ]; if ($template = IncidentTemplate::where('slug', '=', $command->template)->first()) { $data['message'] = $this->parseTemplate($template, $command); } else { $data['message'] = $command->message; } // Link with the component. if ($command->component_id) { $data['component_id'] = $command->component_id; } // The incident occurred at a different time. if ($occurredAt = $command->occurred_at) { if ($date = $this->dates->create('Y-m-d H:i', $occurredAt)) { $data['occurred_at'] = $date; } else { throw new InvalidIncidentTimestampException("Unable to pass timestamp {$occurredAt}"); } } else { $data['occurred_at'] = Carbon::now(); } // Create the incident $incident = Incident::create($data); // 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 IncidentWasCreatedEvent($this->auth->user(), $incident, (bool) $command->notify)); return $incident; }
php
public function handle(CreateIncidentCommand $command) { $data = [ 'user_id' => $this->auth->user()->id, 'name' => $command->name, 'status' => $command->status, 'visible' => $command->visible, 'stickied' => $command->stickied, ]; if ($template = IncidentTemplate::where('slug', '=', $command->template)->first()) { $data['message'] = $this->parseTemplate($template, $command); } else { $data['message'] = $command->message; } // Link with the component. if ($command->component_id) { $data['component_id'] = $command->component_id; } // The incident occurred at a different time. if ($occurredAt = $command->occurred_at) { if ($date = $this->dates->create('Y-m-d H:i', $occurredAt)) { $data['occurred_at'] = $date; } else { throw new InvalidIncidentTimestampException("Unable to pass timestamp {$occurredAt}"); } } else { $data['occurred_at'] = Carbon::now(); } // Create the incident $incident = Incident::create($data); // 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 IncidentWasCreatedEvent($this->auth->user(), $incident, (bool) $command->notify)); return $incident; }
[ "public", "function", "handle", "(", "CreateIncidentCommand", "$", "command", ")", "{", "$", "data", "=", "[", "'user_id'", "=>", "$", "this", "->", "auth", "->", "user", "(", ")", "->", "id", ",", "'name'", "=>", "$", "command", "->", "name", ",", "'status'", "=>", "$", "command", "->", "status", ",", "'visible'", "=>", "$", "command", "->", "visible", ",", "'stickied'", "=>", "$", "command", "->", "stickied", ",", "]", ";", "if", "(", "$", "template", "=", "IncidentTemplate", "::", "where", "(", "'slug'", ",", "'='", ",", "$", "command", "->", "template", ")", "->", "first", "(", ")", ")", "{", "$", "data", "[", "'message'", "]", "=", "$", "this", "->", "parseTemplate", "(", "$", "template", ",", "$", "command", ")", ";", "}", "else", "{", "$", "data", "[", "'message'", "]", "=", "$", "command", "->", "message", ";", "}", "// Link with the component.", "if", "(", "$", "command", "->", "component_id", ")", "{", "$", "data", "[", "'component_id'", "]", "=", "$", "command", "->", "component_id", ";", "}", "// The incident occurred at a different time.", "if", "(", "$", "occurredAt", "=", "$", "command", "->", "occurred_at", ")", "{", "if", "(", "$", "date", "=", "$", "this", "->", "dates", "->", "create", "(", "'Y-m-d H:i'", ",", "$", "occurredAt", ")", ")", "{", "$", "data", "[", "'occurred_at'", "]", "=", "$", "date", ";", "}", "else", "{", "throw", "new", "InvalidIncidentTimestampException", "(", "\"Unable to pass timestamp {$occurredAt}\"", ")", ";", "}", "}", "else", "{", "$", "data", "[", "'occurred_at'", "]", "=", "Carbon", "::", "now", "(", ")", ";", "}", "// Create the incident", "$", "incident", "=", "Incident", "::", "create", "(", "$", "data", ")", ";", "// 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", "IncidentWasCreatedEvent", "(", "$", "this", "->", "auth", "->", "user", "(", ")", ",", "$", "incident", ",", "(", "bool", ")", "$", "command", "->", "notify", ")", ")", ";", "return", "$", "incident", ";", "}" ]
Handle the create incident command. @param \CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand $command @return \CachetHQ\Cachet\Models\Incident
[ "Handle", "the", "create", "incident", "command", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Incident/CreateIncidentCommandHandler.php#L73-L132
220,851
CachetHQ/Cachet
app/Http/Controllers/Dashboard/MetricController.php
MetricController.showMetrics
public function showMetrics() { $metrics = Metric::orderBy('order')->orderBy('id')->get(); return View::make('dashboard.metrics.index') ->withPageTitle(trans('dashboard.metrics.metrics').' - '.trans('dashboard.dashboard')) ->withMetrics($metrics); }
php
public function showMetrics() { $metrics = Metric::orderBy('order')->orderBy('id')->get(); return View::make('dashboard.metrics.index') ->withPageTitle(trans('dashboard.metrics.metrics').' - '.trans('dashboard.dashboard')) ->withMetrics($metrics); }
[ "public", "function", "showMetrics", "(", ")", "{", "$", "metrics", "=", "Metric", "::", "orderBy", "(", "'order'", ")", "->", "orderBy", "(", "'id'", ")", "->", "get", "(", ")", ";", "return", "View", "::", "make", "(", "'dashboard.metrics.index'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.metrics.metrics'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withMetrics", "(", "$", "metrics", ")", ";", "}" ]
Shows the metrics view. @return \Illuminate\View\View
[ "Shows", "the", "metrics", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/MetricController.php#L31-L38
220,852
CachetHQ/Cachet
app/Http/Controllers/Dashboard/MetricController.php
MetricController.createMetricAction
public function createMetricAction() { $metricData = Binput::get('metric'); try { execute(new CreateMetricCommand( $metricData['name'], $metricData['suffix'], $metricData['description'], $metricData['default_value'], $metricData['calc_type'], $metricData['display_chart'], $metricData['places'], $metricData['default_view'], $metricData['threshold'], 0, // Default order $metricData['visible'] )); } catch (ValidationException $e) { return cachet_redirect('dashboard.metrics.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.metrics') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.add.success'))); }
php
public function createMetricAction() { $metricData = Binput::get('metric'); try { execute(new CreateMetricCommand( $metricData['name'], $metricData['suffix'], $metricData['description'], $metricData['default_value'], $metricData['calc_type'], $metricData['display_chart'], $metricData['places'], $metricData['default_view'], $metricData['threshold'], 0, // Default order $metricData['visible'] )); } catch (ValidationException $e) { return cachet_redirect('dashboard.metrics.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.metrics') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.add.success'))); }
[ "public", "function", "createMetricAction", "(", ")", "{", "$", "metricData", "=", "Binput", "::", "get", "(", "'metric'", ")", ";", "try", "{", "execute", "(", "new", "CreateMetricCommand", "(", "$", "metricData", "[", "'name'", "]", ",", "$", "metricData", "[", "'suffix'", "]", ",", "$", "metricData", "[", "'description'", "]", ",", "$", "metricData", "[", "'default_value'", "]", ",", "$", "metricData", "[", "'calc_type'", "]", ",", "$", "metricData", "[", "'display_chart'", "]", ",", "$", "metricData", "[", "'places'", "]", ",", "$", "metricData", "[", "'default_view'", "]", ",", "$", "metricData", "[", "'threshold'", "]", ",", "0", ",", "// Default order", "$", "metricData", "[", "'visible'", "]", ")", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "return", "cachet_redirect", "(", "'dashboard.metrics.create'", ")", "->", "withInput", "(", "Binput", "::", "all", "(", ")", ")", "->", "withTitle", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.whoops'", ")", ",", "trans", "(", "'dashboard.metrics.add.failure'", ")", ")", ")", "->", "withErrors", "(", "$", "e", "->", "getMessageBag", "(", ")", ")", ";", "}", "return", "cachet_redirect", "(", "'dashboard.metrics'", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.metrics.add.success'", ")", ")", ")", ";", "}" ]
Creates a new metric. @return \Illuminate\Http\RedirectResponse
[ "Creates", "a", "new", "metric", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/MetricController.php#L69-L96
220,853
CachetHQ/Cachet
app/Http/Controllers/Dashboard/MetricController.php
MetricController.deleteMetricAction
public function deleteMetricAction(Metric $metric) { execute(new RemoveMetricCommand($metric)); return cachet_redirect('dashboard.metrics') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.delete.success'))); }
php
public function deleteMetricAction(Metric $metric) { execute(new RemoveMetricCommand($metric)); return cachet_redirect('dashboard.metrics') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.delete.success'))); }
[ "public", "function", "deleteMetricAction", "(", "Metric", "$", "metric", ")", "{", "execute", "(", "new", "RemoveMetricCommand", "(", "$", "metric", ")", ")", ";", "return", "cachet_redirect", "(", "'dashboard.metrics'", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.metrics.delete.success'", ")", ")", ")", ";", "}" ]
Deletes a given metric. @param \CachetHQ\Cachet\Models\Metric $metric @return \Illuminate\Http\RedirectResponse
[ "Deletes", "a", "given", "metric", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/MetricController.php#L116-L122
220,854
CachetHQ/Cachet
app/Http/Controllers/Dashboard/MetricController.php
MetricController.showEditMetricAction
public function showEditMetricAction(Metric $metric) { return View::make('dashboard.metrics.edit') ->withPageTitle(trans('dashboard.metrics.edit.title').' - '.trans('dashboard.dashboard')) ->withMetric($metric) ->withAcceptableThresholds(Metric::ACCEPTABLE_THRESHOLDS); }
php
public function showEditMetricAction(Metric $metric) { return View::make('dashboard.metrics.edit') ->withPageTitle(trans('dashboard.metrics.edit.title').' - '.trans('dashboard.dashboard')) ->withMetric($metric) ->withAcceptableThresholds(Metric::ACCEPTABLE_THRESHOLDS); }
[ "public", "function", "showEditMetricAction", "(", "Metric", "$", "metric", ")", "{", "return", "View", "::", "make", "(", "'dashboard.metrics.edit'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.metrics.edit.title'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withMetric", "(", "$", "metric", ")", "->", "withAcceptableThresholds", "(", "Metric", "::", "ACCEPTABLE_THRESHOLDS", ")", ";", "}" ]
Shows the edit metric view. @param \CachetHQ\Cachet\Models\Metric $metric @return \Illuminate\View\View
[ "Shows", "the", "edit", "metric", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/MetricController.php#L131-L137
220,855
CachetHQ/Cachet
app/Http/Controllers/Dashboard/MetricController.php
MetricController.editMetricAction
public function editMetricAction(Metric $metric) { try { execute(new UpdateMetricCommand( $metric, Binput::get('name', null, false), Binput::get('suffix', null, false), Binput::get('description', null, false), Binput::get('default_value', null, false), Binput::get('calc_type', null, false), Binput::get('display_chart', null, false), Binput::get('places', null, false), Binput::get('default_view', null, false), Binput::get('threshold', null, false), null, Binput::get('visible', null, false) )); } catch (ValidationException $e) { return cachet_redirect('dashboard.metrics.edit', [$metric->id]) ->withInput(Binput::all()) ->withTitle(sprintf('<strong>%s</strong>', trans('dashboard.notifications.whoops'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.metrics.edit', [$metric->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.edit.success'))); }
php
public function editMetricAction(Metric $metric) { try { execute(new UpdateMetricCommand( $metric, Binput::get('name', null, false), Binput::get('suffix', null, false), Binput::get('description', null, false), Binput::get('default_value', null, false), Binput::get('calc_type', null, false), Binput::get('display_chart', null, false), Binput::get('places', null, false), Binput::get('default_view', null, false), Binput::get('threshold', null, false), null, Binput::get('visible', null, false) )); } catch (ValidationException $e) { return cachet_redirect('dashboard.metrics.edit', [$metric->id]) ->withInput(Binput::all()) ->withTitle(sprintf('<strong>%s</strong>', trans('dashboard.notifications.whoops'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.metrics.edit', [$metric->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.edit.success'))); }
[ "public", "function", "editMetricAction", "(", "Metric", "$", "metric", ")", "{", "try", "{", "execute", "(", "new", "UpdateMetricCommand", "(", "$", "metric", ",", "Binput", "::", "get", "(", "'name'", ",", "null", ",", "false", ")", ",", "Binput", "::", "get", "(", "'suffix'", ",", "null", ",", "false", ")", ",", "Binput", "::", "get", "(", "'description'", ",", "null", ",", "false", ")", ",", "Binput", "::", "get", "(", "'default_value'", ",", "null", ",", "false", ")", ",", "Binput", "::", "get", "(", "'calc_type'", ",", "null", ",", "false", ")", ",", "Binput", "::", "get", "(", "'display_chart'", ",", "null", ",", "false", ")", ",", "Binput", "::", "get", "(", "'places'", ",", "null", ",", "false", ")", ",", "Binput", "::", "get", "(", "'default_view'", ",", "null", ",", "false", ")", ",", "Binput", "::", "get", "(", "'threshold'", ",", "null", ",", "false", ")", ",", "null", ",", "Binput", "::", "get", "(", "'visible'", ",", "null", ",", "false", ")", ")", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "return", "cachet_redirect", "(", "'dashboard.metrics.edit'", ",", "[", "$", "metric", "->", "id", "]", ")", "->", "withInput", "(", "Binput", "::", "all", "(", ")", ")", "->", "withTitle", "(", "sprintf", "(", "'<strong>%s</strong>'", ",", "trans", "(", "'dashboard.notifications.whoops'", ")", ")", ")", "->", "withErrors", "(", "$", "e", "->", "getMessageBag", "(", ")", ")", ";", "}", "return", "cachet_redirect", "(", "'dashboard.metrics.edit'", ",", "[", "$", "metric", "->", "id", "]", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.metrics.edit.success'", ")", ")", ")", ";", "}" ]
Edit an metric. @param \CachetHQ\Cachet\Models\Metric $metric @return \Illuminate\Http\RedirectResponse
[ "Edit", "an", "metric", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/MetricController.php#L146-L172
220,856
CachetHQ/Cachet
app/Models/Traits/SortableTrait.php
SortableTrait.scopeSort
public function scopeSort(Builder $query, $column, $direction) { if (!in_array($column, $this->sortable)) { return $query; } return $query->orderBy($column, $direction); }
php
public function scopeSort(Builder $query, $column, $direction) { if (!in_array($column, $this->sortable)) { return $query; } return $query->orderBy($column, $direction); }
[ "public", "function", "scopeSort", "(", "Builder", "$", "query", ",", "$", "column", ",", "$", "direction", ")", "{", "if", "(", "!", "in_array", "(", "$", "column", ",", "$", "this", "->", "sortable", ")", ")", "{", "return", "$", "query", ";", "}", "return", "$", "query", "->", "orderBy", "(", "$", "column", ",", "$", "direction", ")", ";", "}" ]
Adds a sort scope. @param \Illuminate\Database\Eloquent\Builder $query @param string $column @param string $direction @return \Illuminate\Database\Eloquent\Builder
[ "Adds", "a", "sort", "scope", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Models/Traits/SortableTrait.php#L32-L39
220,857
CachetHQ/Cachet
app/Settings/Repository.php
Repository.all
public function all() { try { return $this->model->all(['name', 'value'])->pluck('value', 'name')->map(function ($value, $name) { return $this->castSetting($name, $value); })->toArray(); } catch (Exception $e) { throw new ReadException($e); } }
php
public function all() { try { return $this->model->all(['name', 'value'])->pluck('value', 'name')->map(function ($value, $name) { return $this->castSetting($name, $value); })->toArray(); } catch (Exception $e) { throw new ReadException($e); } }
[ "public", "function", "all", "(", ")", "{", "try", "{", "return", "$", "this", "->", "model", "->", "all", "(", "[", "'name'", ",", "'value'", "]", ")", "->", "pluck", "(", "'value'", ",", "'name'", ")", "->", "map", "(", "function", "(", "$", "value", ",", "$", "name", ")", "{", "return", "$", "this", "->", "castSetting", "(", "$", "name", ",", "$", "value", ")", ";", "}", ")", "->", "toArray", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "ReadException", "(", "$", "e", ")", ";", "}", "}" ]
Returns a setting from the database. @throws \CachetHQ\Cachet\Settings\ReadException @return array
[ "Returns", "a", "setting", "from", "the", "database", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Settings/Repository.php#L67-L76
220,858
CachetHQ/Cachet
app/Settings/Repository.php
Repository.set
public function set($name, $value) { $this->stale = true; try { if ($value === null) { $this->model->where('name', '=', $name)->delete(); } else { $this->model->updateOrCreate(compact('name'), compact('value')); } } catch (Exception $e) { throw new WriteException($e); } }
php
public function set($name, $value) { $this->stale = true; try { if ($value === null) { $this->model->where('name', '=', $name)->delete(); } else { $this->model->updateOrCreate(compact('name'), compact('value')); } } catch (Exception $e) { throw new WriteException($e); } }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", ")", "{", "$", "this", "->", "stale", "=", "true", ";", "try", "{", "if", "(", "$", "value", "===", "null", ")", "{", "$", "this", "->", "model", "->", "where", "(", "'name'", ",", "'='", ",", "$", "name", ")", "->", "delete", "(", ")", ";", "}", "else", "{", "$", "this", "->", "model", "->", "updateOrCreate", "(", "compact", "(", "'name'", ")", ",", "compact", "(", "'value'", ")", ")", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "WriteException", "(", "$", "e", ")", ";", "}", "}" ]
Updates a setting value. @param string $name @param string|null $value @throws \CachetHQ\Cachet\Settings\WriteException @return void
[ "Updates", "a", "setting", "value", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Settings/Repository.php#L88-L101
220,859
CachetHQ/Cachet
app/Settings/Repository.php
Repository.get
public function get($name, $default = null) { try { if ($setting = $this->model->where('name', '=', $name)->first()) { return $this->castSetting($name, $setting->value); } return $default; } catch (Exception $e) { throw new ReadException($e); } }
php
public function get($name, $default = null) { try { if ($setting = $this->model->where('name', '=', $name)->first()) { return $this->castSetting($name, $setting->value); } return $default; } catch (Exception $e) { throw new ReadException($e); } }
[ "public", "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "try", "{", "if", "(", "$", "setting", "=", "$", "this", "->", "model", "->", "where", "(", "'name'", ",", "'='", ",", "$", "name", ")", "->", "first", "(", ")", ")", "{", "return", "$", "this", "->", "castSetting", "(", "$", "name", ",", "$", "setting", "->", "value", ")", ";", "}", "return", "$", "default", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "ReadException", "(", "$", "e", ")", ";", "}", "}" ]
Get a setting, or the default value. @param string $name @param mixed $default @throws \CachetHQ\Cachet\Settings\ReadException @return mixed
[ "Get", "a", "setting", "or", "the", "default", "value", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Settings/Repository.php#L113-L124
220,860
CachetHQ/Cachet
app/Settings/Repository.php
Repository.clear
public function clear() { $this->stale = true; try { $this->model->query()->delete(); } catch (Exception $e) { throw new WriteException($e); } }
php
public function clear() { $this->stale = true; try { $this->model->query()->delete(); } catch (Exception $e) { throw new WriteException($e); } }
[ "public", "function", "clear", "(", ")", "{", "$", "this", "->", "stale", "=", "true", ";", "try", "{", "$", "this", "->", "model", "->", "query", "(", ")", "->", "delete", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "WriteException", "(", "$", "e", ")", ";", "}", "}" ]
Clear all settings. @throws \CachetHQ\Cachet\Settings\WriteException @return void
[ "Clear", "all", "settings", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Settings/Repository.php#L153-L162
220,861
CachetHQ/Cachet
app/Settings/Repository.php
Repository.castSetting
protected function castSetting($key, $value) { if (is_null($value)) { return $value; } if (!in_array($key, $this->notBooleans) && in_array($value, ['0', '1'])) { return (bool) $value; } return $value; }
php
protected function castSetting($key, $value) { if (is_null($value)) { return $value; } if (!in_array($key, $this->notBooleans) && in_array($value, ['0', '1'])) { return (bool) $value; } return $value; }
[ "protected", "function", "castSetting", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "if", "(", "!", "in_array", "(", "$", "key", ",", "$", "this", "->", "notBooleans", ")", "&&", "in_array", "(", "$", "value", ",", "[", "'0'", ",", "'1'", "]", ")", ")", "{", "return", "(", "bool", ")", "$", "value", ";", "}", "return", "$", "value", ";", "}" ]
Cast setting as the applicable type. @param string $key @param string $value @return mixed
[ "Cast", "setting", "as", "the", "applicable", "type", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Settings/Repository.php#L182-L193
220,862
CachetHQ/Cachet
app/Presenters/IncidentPresenter.php
IncidentPresenter.icon
public function icon() { if (isset($this->icons[$this->wrappedObject->status])) { return $this->icons[$this->wrappedObject->status]; } }
php
public function icon() { if (isset($this->icons[$this->wrappedObject->status])) { return $this->icons[$this->wrappedObject->status]; } }
[ "public", "function", "icon", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "icons", "[", "$", "this", "->", "wrappedObject", "->", "status", "]", ")", ")", "{", "return", "$", "this", "->", "icons", "[", "$", "this", "->", "wrappedObject", "->", "status", "]", ";", "}", "}" ]
Present the status with an icon. @return string
[ "Present", "the", "status", "with", "an", "icon", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Presenters/IncidentPresenter.php#L190-L195
220,863
CachetHQ/Cachet
app/Bus/Handlers/Commands/Metric/CreateMetricCommandHandler.php
CreateMetricCommandHandler.handle
public function handle(CreateMetricCommand $command) { $metric = Metric::create([ 'name' => $command->name, 'suffix' => $command->suffix, 'description' => $command->description, 'default_value' => $command->default_value, 'calc_type' => $command->calc_type, 'display_chart' => $command->display_chart, 'places' => $command->places, 'default_view' => $command->default_view, 'threshold' => $command->threshold, 'order' => $command->order, 'visible' => $command->visible, ]); event(new MetricWasCreatedEvent($this->auth->user(), $metric)); return $metric; }
php
public function handle(CreateMetricCommand $command) { $metric = Metric::create([ 'name' => $command->name, 'suffix' => $command->suffix, 'description' => $command->description, 'default_value' => $command->default_value, 'calc_type' => $command->calc_type, 'display_chart' => $command->display_chart, 'places' => $command->places, 'default_view' => $command->default_view, 'threshold' => $command->threshold, 'order' => $command->order, 'visible' => $command->visible, ]); event(new MetricWasCreatedEvent($this->auth->user(), $metric)); return $metric; }
[ "public", "function", "handle", "(", "CreateMetricCommand", "$", "command", ")", "{", "$", "metric", "=", "Metric", "::", "create", "(", "[", "'name'", "=>", "$", "command", "->", "name", ",", "'suffix'", "=>", "$", "command", "->", "suffix", ",", "'description'", "=>", "$", "command", "->", "description", ",", "'default_value'", "=>", "$", "command", "->", "default_value", ",", "'calc_type'", "=>", "$", "command", "->", "calc_type", ",", "'display_chart'", "=>", "$", "command", "->", "display_chart", ",", "'places'", "=>", "$", "command", "->", "places", ",", "'default_view'", "=>", "$", "command", "->", "default_view", ",", "'threshold'", "=>", "$", "command", "->", "threshold", ",", "'order'", "=>", "$", "command", "->", "order", ",", "'visible'", "=>", "$", "command", "->", "visible", ",", "]", ")", ";", "event", "(", "new", "MetricWasCreatedEvent", "(", "$", "this", "->", "auth", "->", "user", "(", ")", ",", "$", "metric", ")", ")", ";", "return", "$", "metric", ";", "}" ]
Handle the add metric command. @param \CachetHQ\Cachet\Bus\Commands\Metric\CreateMetricCommand $command @return \CachetHQ\Cachet\Models\Metric
[ "Handle", "the", "add", "metric", "command", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Metric/CreateMetricCommandHandler.php#L47-L66
220,864
CachetHQ/Cachet
app/Http/Controllers/Api/ComponentController.php
ComponentController.index
public function index() { if (app(Guard::class)->check()) { $components = Component::query(); } else { $components = Component::enabled(); } if ($tags = Binput::get('tags')) { $components->withAnyTags($tags); } $components->search(Binput::except(['sort', 'order', 'per_page'])); if ($sortBy = Binput::get('sort')) { $direction = Binput::has('order') && Binput::get('order') == 'desc'; $components->sort($sortBy, $direction); } $components = $components->paginate(Binput::get('per_page', 20)); return $this->paginator($components, Request::instance()); }
php
public function index() { if (app(Guard::class)->check()) { $components = Component::query(); } else { $components = Component::enabled(); } if ($tags = Binput::get('tags')) { $components->withAnyTags($tags); } $components->search(Binput::except(['sort', 'order', 'per_page'])); if ($sortBy = Binput::get('sort')) { $direction = Binput::has('order') && Binput::get('order') == 'desc'; $components->sort($sortBy, $direction); } $components = $components->paginate(Binput::get('per_page', 20)); return $this->paginator($components, Request::instance()); }
[ "public", "function", "index", "(", ")", "{", "if", "(", "app", "(", "Guard", "::", "class", ")", "->", "check", "(", ")", ")", "{", "$", "components", "=", "Component", "::", "query", "(", ")", ";", "}", "else", "{", "$", "components", "=", "Component", "::", "enabled", "(", ")", ";", "}", "if", "(", "$", "tags", "=", "Binput", "::", "get", "(", "'tags'", ")", ")", "{", "$", "components", "->", "withAnyTags", "(", "$", "tags", ")", ";", "}", "$", "components", "->", "search", "(", "Binput", "::", "except", "(", "[", "'sort'", ",", "'order'", ",", "'per_page'", "]", ")", ")", ";", "if", "(", "$", "sortBy", "=", "Binput", "::", "get", "(", "'sort'", ")", ")", "{", "$", "direction", "=", "Binput", "::", "has", "(", "'order'", ")", "&&", "Binput", "::", "get", "(", "'order'", ")", "==", "'desc'", ";", "$", "components", "->", "sort", "(", "$", "sortBy", ",", "$", "direction", ")", ";", "}", "$", "components", "=", "$", "components", "->", "paginate", "(", "Binput", "::", "get", "(", "'per_page'", ",", "20", ")", ")", ";", "return", "$", "this", "->", "paginator", "(", "$", "components", ",", "Request", "::", "instance", "(", ")", ")", ";", "}" ]
Get all components. @return \Illuminate\Http\JsonResponse
[ "Get", "all", "components", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/ComponentController.php#L34-L57
220,865
CachetHQ/Cachet
app/Http/Controllers/Api/ComponentController.php
ComponentController.store
public function store() { try { $component = execute(new CreateComponentCommand( Binput::get('name'), Binput::get('description'), Binput::get('status'), Binput::get('link'), Binput::get('order'), Binput::get('group_id'), (bool) Binput::get('enabled', true), Binput::get('meta', null) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } if (Binput::has('tags')) { $component->tags()->delete(); // The component was added successfully, so now let's deal with the tags. Collection::make(preg_split('/ ?, ?/', $tags))->map(function ($tag) { return trim($tag); })->map(function ($tag) { return execute(new CreateTagCommand($tag)); })->each(function ($tag) use ($component) { execute(new ApplyTagCommand($component, $tag)); }); } return $this->item($component); }
php
public function store() { try { $component = execute(new CreateComponentCommand( Binput::get('name'), Binput::get('description'), Binput::get('status'), Binput::get('link'), Binput::get('order'), Binput::get('group_id'), (bool) Binput::get('enabled', true), Binput::get('meta', null) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } if (Binput::has('tags')) { $component->tags()->delete(); // The component was added successfully, so now let's deal with the tags. Collection::make(preg_split('/ ?, ?/', $tags))->map(function ($tag) { return trim($tag); })->map(function ($tag) { return execute(new CreateTagCommand($tag)); })->each(function ($tag) use ($component) { execute(new ApplyTagCommand($component, $tag)); }); } return $this->item($component); }
[ "public", "function", "store", "(", ")", "{", "try", "{", "$", "component", "=", "execute", "(", "new", "CreateComponentCommand", "(", "Binput", "::", "get", "(", "'name'", ")", ",", "Binput", "::", "get", "(", "'description'", ")", ",", "Binput", "::", "get", "(", "'status'", ")", ",", "Binput", "::", "get", "(", "'link'", ")", ",", "Binput", "::", "get", "(", "'order'", ")", ",", "Binput", "::", "get", "(", "'group_id'", ")", ",", "(", "bool", ")", "Binput", "::", "get", "(", "'enabled'", ",", "true", ")", ",", "Binput", "::", "get", "(", "'meta'", ",", "null", ")", ")", ")", ";", "}", "catch", "(", "QueryException", "$", "e", ")", "{", "throw", "new", "BadRequestHttpException", "(", ")", ";", "}", "if", "(", "Binput", "::", "has", "(", "'tags'", ")", ")", "{", "$", "component", "->", "tags", "(", ")", "->", "delete", "(", ")", ";", "// The component was added successfully, so now let's deal with the tags.", "Collection", "::", "make", "(", "preg_split", "(", "'/ ?, ?/'", ",", "$", "tags", ")", ")", "->", "map", "(", "function", "(", "$", "tag", ")", "{", "return", "trim", "(", "$", "tag", ")", ";", "}", ")", "->", "map", "(", "function", "(", "$", "tag", ")", "{", "return", "execute", "(", "new", "CreateTagCommand", "(", "$", "tag", ")", ")", ";", "}", ")", "->", "each", "(", "function", "(", "$", "tag", ")", "use", "(", "$", "component", ")", "{", "execute", "(", "new", "ApplyTagCommand", "(", "$", "component", ",", "$", "tag", ")", ")", ";", "}", ")", ";", "}", "return", "$", "this", "->", "item", "(", "$", "component", ")", ";", "}" ]
Create a new component. @return \Illuminate\Http\JsonResponse
[ "Create", "a", "new", "component", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/ComponentController.php#L76-L107
220,866
CachetHQ/Cachet
app/Http/Controllers/Api/ComponentController.php
ComponentController.update
public function update(Component $component) { try { execute(new UpdateComponentCommand( $component, Binput::get('name'), Binput::get('description'), Binput::get('status'), Binput::get('link'), Binput::get('order'), Binput::get('group_id'), Binput::get('enabled', $component->enabled), Binput::get('meta', null), (bool) Binput::get('silent', false) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } if (Binput::has('tags')) { $component->tags()->delete(); // The component was added successfully, so now let's deal with the tags. Collection::make(preg_split('/ ?, ?/', $tags))->map(function ($tag) { return trim($tag); })->map(function ($tag) { return execute(new CreateTagCommand($tag)); })->each(function ($tag) use ($component) { execute(new ApplyTagCommand($component, $tag)); }); } return $this->item($component); }
php
public function update(Component $component) { try { execute(new UpdateComponentCommand( $component, Binput::get('name'), Binput::get('description'), Binput::get('status'), Binput::get('link'), Binput::get('order'), Binput::get('group_id'), Binput::get('enabled', $component->enabled), Binput::get('meta', null), (bool) Binput::get('silent', false) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } if (Binput::has('tags')) { $component->tags()->delete(); // The component was added successfully, so now let's deal with the tags. Collection::make(preg_split('/ ?, ?/', $tags))->map(function ($tag) { return trim($tag); })->map(function ($tag) { return execute(new CreateTagCommand($tag)); })->each(function ($tag) use ($component) { execute(new ApplyTagCommand($component, $tag)); }); } return $this->item($component); }
[ "public", "function", "update", "(", "Component", "$", "component", ")", "{", "try", "{", "execute", "(", "new", "UpdateComponentCommand", "(", "$", "component", ",", "Binput", "::", "get", "(", "'name'", ")", ",", "Binput", "::", "get", "(", "'description'", ")", ",", "Binput", "::", "get", "(", "'status'", ")", ",", "Binput", "::", "get", "(", "'link'", ")", ",", "Binput", "::", "get", "(", "'order'", ")", ",", "Binput", "::", "get", "(", "'group_id'", ")", ",", "Binput", "::", "get", "(", "'enabled'", ",", "$", "component", "->", "enabled", ")", ",", "Binput", "::", "get", "(", "'meta'", ",", "null", ")", ",", "(", "bool", ")", "Binput", "::", "get", "(", "'silent'", ",", "false", ")", ")", ")", ";", "}", "catch", "(", "QueryException", "$", "e", ")", "{", "throw", "new", "BadRequestHttpException", "(", ")", ";", "}", "if", "(", "Binput", "::", "has", "(", "'tags'", ")", ")", "{", "$", "component", "->", "tags", "(", ")", "->", "delete", "(", ")", ";", "// The component was added successfully, so now let's deal with the tags.", "Collection", "::", "make", "(", "preg_split", "(", "'/ ?, ?/'", ",", "$", "tags", ")", ")", "->", "map", "(", "function", "(", "$", "tag", ")", "{", "return", "trim", "(", "$", "tag", ")", ";", "}", ")", "->", "map", "(", "function", "(", "$", "tag", ")", "{", "return", "execute", "(", "new", "CreateTagCommand", "(", "$", "tag", ")", ")", ";", "}", ")", "->", "each", "(", "function", "(", "$", "tag", ")", "use", "(", "$", "component", ")", "{", "execute", "(", "new", "ApplyTagCommand", "(", "$", "component", ",", "$", "tag", ")", ")", ";", "}", ")", ";", "}", "return", "$", "this", "->", "item", "(", "$", "component", ")", ";", "}" ]
Update an existing component. @param \CachetHQ\Cachet\Models\Component $component @return \Illuminate\Http\JsonResponse
[ "Update", "an", "existing", "component", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/ComponentController.php#L116-L149
220,867
CachetHQ/Cachet
app/Http/Controllers/SetupController.php
SetupController.getIndex
public function getIndex() { $supportedLanguages = Request::getLanguages(); $userLanguage = Config::get('app.locale'); foreach ($supportedLanguages as $language) { $language = str_replace('_', '-', $language); if (isset($this->langs[$language])) { $userLanguage = $language; break; } } // Since .env may already be configured, we should show that data! $cacheConfig = [ 'driver' => Config::get('cache.default'), ]; $sessionConfig = [ 'driver' => Config::get('session.driver'), ]; $queueConfig = [ 'driver' => Config::get('queue.default'), ]; $mailConfig = [ 'driver' => Config::get('mail.driver'), 'host' => Config::get('mail.host'), 'from' => Config::get('mail.from'), 'username' => Config::get('mail.username'), 'password' => Config::get('mail.password'), ]; return View::make('setup.index') ->withPageTitle(trans('setup.setup')) ->withCacheDrivers($this->cacheDrivers) ->withQueueDrivers($this->queueDrivers) ->withMailDrivers($this->mailDrivers) ->withUserLanguage($userLanguage) ->withAppUrl(Request::root()) ->withCacheConfig($cacheConfig) ->withSessionConfig($sessionConfig) ->withQueueConfig($queueConfig) ->withMailConfig($mailConfig); }
php
public function getIndex() { $supportedLanguages = Request::getLanguages(); $userLanguage = Config::get('app.locale'); foreach ($supportedLanguages as $language) { $language = str_replace('_', '-', $language); if (isset($this->langs[$language])) { $userLanguage = $language; break; } } // Since .env may already be configured, we should show that data! $cacheConfig = [ 'driver' => Config::get('cache.default'), ]; $sessionConfig = [ 'driver' => Config::get('session.driver'), ]; $queueConfig = [ 'driver' => Config::get('queue.default'), ]; $mailConfig = [ 'driver' => Config::get('mail.driver'), 'host' => Config::get('mail.host'), 'from' => Config::get('mail.from'), 'username' => Config::get('mail.username'), 'password' => Config::get('mail.password'), ]; return View::make('setup.index') ->withPageTitle(trans('setup.setup')) ->withCacheDrivers($this->cacheDrivers) ->withQueueDrivers($this->queueDrivers) ->withMailDrivers($this->mailDrivers) ->withUserLanguage($userLanguage) ->withAppUrl(Request::root()) ->withCacheConfig($cacheConfig) ->withSessionConfig($sessionConfig) ->withQueueConfig($queueConfig) ->withMailConfig($mailConfig); }
[ "public", "function", "getIndex", "(", ")", "{", "$", "supportedLanguages", "=", "Request", "::", "getLanguages", "(", ")", ";", "$", "userLanguage", "=", "Config", "::", "get", "(", "'app.locale'", ")", ";", "foreach", "(", "$", "supportedLanguages", "as", "$", "language", ")", "{", "$", "language", "=", "str_replace", "(", "'_'", ",", "'-'", ",", "$", "language", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "langs", "[", "$", "language", "]", ")", ")", "{", "$", "userLanguage", "=", "$", "language", ";", "break", ";", "}", "}", "// Since .env may already be configured, we should show that data!", "$", "cacheConfig", "=", "[", "'driver'", "=>", "Config", "::", "get", "(", "'cache.default'", ")", ",", "]", ";", "$", "sessionConfig", "=", "[", "'driver'", "=>", "Config", "::", "get", "(", "'session.driver'", ")", ",", "]", ";", "$", "queueConfig", "=", "[", "'driver'", "=>", "Config", "::", "get", "(", "'queue.default'", ")", ",", "]", ";", "$", "mailConfig", "=", "[", "'driver'", "=>", "Config", "::", "get", "(", "'mail.driver'", ")", ",", "'host'", "=>", "Config", "::", "get", "(", "'mail.host'", ")", ",", "'from'", "=>", "Config", "::", "get", "(", "'mail.from'", ")", ",", "'username'", "=>", "Config", "::", "get", "(", "'mail.username'", ")", ",", "'password'", "=>", "Config", "::", "get", "(", "'mail.password'", ")", ",", "]", ";", "return", "View", "::", "make", "(", "'setup.index'", ")", "->", "withPageTitle", "(", "trans", "(", "'setup.setup'", ")", ")", "->", "withCacheDrivers", "(", "$", "this", "->", "cacheDrivers", ")", "->", "withQueueDrivers", "(", "$", "this", "->", "queueDrivers", ")", "->", "withMailDrivers", "(", "$", "this", "->", "mailDrivers", ")", "->", "withUserLanguage", "(", "$", "userLanguage", ")", "->", "withAppUrl", "(", "Request", "::", "root", "(", ")", ")", "->", "withCacheConfig", "(", "$", "cacheConfig", ")", "->", "withSessionConfig", "(", "$", "sessionConfig", ")", "->", "withQueueConfig", "(", "$", "queueConfig", ")", "->", "withMailConfig", "(", "$", "mailConfig", ")", ";", "}" ]
Returns the setup page. @return \Illuminate\View\View
[ "Returns", "the", "setup", "page", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/SetupController.php#L135-L181
220,868
CachetHQ/Cachet
app/Http/Controllers/SetupController.php
SetupController.postStep1
public function postStep1() { $postData = Binput::all(); $v = Validator::make($postData, $this->rulesStep1); $v->sometimes('env.mail_host', 'required', function ($input) { return $input->env['mail_driver'] === 'smtp'; }); $v->sometimes(['env.mail_address', 'env.mail_password'], 'required', function ($input) { return !in_array($input->env['mail_driver'], ['log', 'smtp']); }); $v->sometimes(['env.mail_username'], 'required', function ($input) { return !in_array($input->env['mail_driver'], ['sendmail', 'log']); }); if ($v->passes()) { return Response::json(['status' => 1]); } return Response::json(['errors' => $v->getMessageBag()], 400); }
php
public function postStep1() { $postData = Binput::all(); $v = Validator::make($postData, $this->rulesStep1); $v->sometimes('env.mail_host', 'required', function ($input) { return $input->env['mail_driver'] === 'smtp'; }); $v->sometimes(['env.mail_address', 'env.mail_password'], 'required', function ($input) { return !in_array($input->env['mail_driver'], ['log', 'smtp']); }); $v->sometimes(['env.mail_username'], 'required', function ($input) { return !in_array($input->env['mail_driver'], ['sendmail', 'log']); }); if ($v->passes()) { return Response::json(['status' => 1]); } return Response::json(['errors' => $v->getMessageBag()], 400); }
[ "public", "function", "postStep1", "(", ")", "{", "$", "postData", "=", "Binput", "::", "all", "(", ")", ";", "$", "v", "=", "Validator", "::", "make", "(", "$", "postData", ",", "$", "this", "->", "rulesStep1", ")", ";", "$", "v", "->", "sometimes", "(", "'env.mail_host'", ",", "'required'", ",", "function", "(", "$", "input", ")", "{", "return", "$", "input", "->", "env", "[", "'mail_driver'", "]", "===", "'smtp'", ";", "}", ")", ";", "$", "v", "->", "sometimes", "(", "[", "'env.mail_address'", ",", "'env.mail_password'", "]", ",", "'required'", ",", "function", "(", "$", "input", ")", "{", "return", "!", "in_array", "(", "$", "input", "->", "env", "[", "'mail_driver'", "]", ",", "[", "'log'", ",", "'smtp'", "]", ")", ";", "}", ")", ";", "$", "v", "->", "sometimes", "(", "[", "'env.mail_username'", "]", ",", "'required'", ",", "function", "(", "$", "input", ")", "{", "return", "!", "in_array", "(", "$", "input", "->", "env", "[", "'mail_driver'", "]", ",", "[", "'sendmail'", ",", "'log'", "]", ")", ";", "}", ")", ";", "if", "(", "$", "v", "->", "passes", "(", ")", ")", "{", "return", "Response", "::", "json", "(", "[", "'status'", "=>", "1", "]", ")", ";", "}", "return", "Response", "::", "json", "(", "[", "'errors'", "=>", "$", "v", "->", "getMessageBag", "(", ")", "]", ",", "400", ")", ";", "}" ]
Handles validation on step one of the setup form. @return \Illuminate\Http\Response
[ "Handles", "validation", "on", "step", "one", "of", "the", "setup", "form", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/SetupController.php#L188-L211
220,869
CachetHQ/Cachet
app/Http/Controllers/SetupController.php
SetupController.postStep2
public function postStep2() { $postData = Binput::all(); $v = Validator::make($postData, $this->rulesStep1 + $this->rulesStep2); if ($v->passes()) { return Response::json(['status' => 1]); } return Response::json(['errors' => $v->getMessageBag()], 400); }
php
public function postStep2() { $postData = Binput::all(); $v = Validator::make($postData, $this->rulesStep1 + $this->rulesStep2); if ($v->passes()) { return Response::json(['status' => 1]); } return Response::json(['errors' => $v->getMessageBag()], 400); }
[ "public", "function", "postStep2", "(", ")", "{", "$", "postData", "=", "Binput", "::", "all", "(", ")", ";", "$", "v", "=", "Validator", "::", "make", "(", "$", "postData", ",", "$", "this", "->", "rulesStep1", "+", "$", "this", "->", "rulesStep2", ")", ";", "if", "(", "$", "v", "->", "passes", "(", ")", ")", "{", "return", "Response", "::", "json", "(", "[", "'status'", "=>", "1", "]", ")", ";", "}", "return", "Response", "::", "json", "(", "[", "'errors'", "=>", "$", "v", "->", "getMessageBag", "(", ")", "]", ",", "400", ")", ";", "}" ]
Handles validation on step two of the setup form. @return \Illuminate\Http\Response
[ "Handles", "validation", "on", "step", "two", "of", "the", "setup", "form", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/SetupController.php#L218-L229
220,870
CachetHQ/Cachet
app/Http/Controllers/SetupController.php
SetupController.postStep3
public function postStep3() { $postData = Binput::all(); $v = Validator::make($postData, $this->rulesStep1 + $this->rulesStep2 + $this->rulesStep3); if ($v->passes()) { // Pull the user details out. $userDetails = Arr::pull($postData, 'user'); $user = User::create([ 'username' => $userDetails['username'], 'email' => $userDetails['email'], 'password' => $userDetails['password'], 'level' => User::LEVEL_ADMIN, ]); Auth::login($user); $setting = app(Repository::class); $settings = Arr::pull($postData, 'settings'); foreach ($settings as $settingName => $settingValue) { $setting->set($settingName, $settingValue); } $envData = Arr::pull($postData, 'env'); // Write the env to the .env file. execute(new UpdateConfigCommand($envData)); if (Request::ajax()) { return Response::json(['status' => 1]); } return cachet_redirect('dashboard'); } if (Request::ajax()) { return Response::json(['errors' => $v->getMessageBag()], 400); } return cachet_redirect('setup')->withInput()->withErrors($v->getMessageBag()); }
php
public function postStep3() { $postData = Binput::all(); $v = Validator::make($postData, $this->rulesStep1 + $this->rulesStep2 + $this->rulesStep3); if ($v->passes()) { // Pull the user details out. $userDetails = Arr::pull($postData, 'user'); $user = User::create([ 'username' => $userDetails['username'], 'email' => $userDetails['email'], 'password' => $userDetails['password'], 'level' => User::LEVEL_ADMIN, ]); Auth::login($user); $setting = app(Repository::class); $settings = Arr::pull($postData, 'settings'); foreach ($settings as $settingName => $settingValue) { $setting->set($settingName, $settingValue); } $envData = Arr::pull($postData, 'env'); // Write the env to the .env file. execute(new UpdateConfigCommand($envData)); if (Request::ajax()) { return Response::json(['status' => 1]); } return cachet_redirect('dashboard'); } if (Request::ajax()) { return Response::json(['errors' => $v->getMessageBag()], 400); } return cachet_redirect('setup')->withInput()->withErrors($v->getMessageBag()); }
[ "public", "function", "postStep3", "(", ")", "{", "$", "postData", "=", "Binput", "::", "all", "(", ")", ";", "$", "v", "=", "Validator", "::", "make", "(", "$", "postData", ",", "$", "this", "->", "rulesStep1", "+", "$", "this", "->", "rulesStep2", "+", "$", "this", "->", "rulesStep3", ")", ";", "if", "(", "$", "v", "->", "passes", "(", ")", ")", "{", "// Pull the user details out.", "$", "userDetails", "=", "Arr", "::", "pull", "(", "$", "postData", ",", "'user'", ")", ";", "$", "user", "=", "User", "::", "create", "(", "[", "'username'", "=>", "$", "userDetails", "[", "'username'", "]", ",", "'email'", "=>", "$", "userDetails", "[", "'email'", "]", ",", "'password'", "=>", "$", "userDetails", "[", "'password'", "]", ",", "'level'", "=>", "User", "::", "LEVEL_ADMIN", ",", "]", ")", ";", "Auth", "::", "login", "(", "$", "user", ")", ";", "$", "setting", "=", "app", "(", "Repository", "::", "class", ")", ";", "$", "settings", "=", "Arr", "::", "pull", "(", "$", "postData", ",", "'settings'", ")", ";", "foreach", "(", "$", "settings", "as", "$", "settingName", "=>", "$", "settingValue", ")", "{", "$", "setting", "->", "set", "(", "$", "settingName", ",", "$", "settingValue", ")", ";", "}", "$", "envData", "=", "Arr", "::", "pull", "(", "$", "postData", ",", "'env'", ")", ";", "// Write the env to the .env file.", "execute", "(", "new", "UpdateConfigCommand", "(", "$", "envData", ")", ")", ";", "if", "(", "Request", "::", "ajax", "(", ")", ")", "{", "return", "Response", "::", "json", "(", "[", "'status'", "=>", "1", "]", ")", ";", "}", "return", "cachet_redirect", "(", "'dashboard'", ")", ";", "}", "if", "(", "Request", "::", "ajax", "(", ")", ")", "{", "return", "Response", "::", "json", "(", "[", "'errors'", "=>", "$", "v", "->", "getMessageBag", "(", ")", "]", ",", "400", ")", ";", "}", "return", "cachet_redirect", "(", "'setup'", ")", "->", "withInput", "(", ")", "->", "withErrors", "(", "$", "v", "->", "getMessageBag", "(", ")", ")", ";", "}" ]
Handles the actual app setup, including user, settings and env. @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
[ "Handles", "the", "actual", "app", "setup", "including", "user", "settings", "and", "env", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/SetupController.php#L236-L280
220,871
CachetHQ/Cachet
app/Foundation/Providers/IntegrationServiceProvider.php
IntegrationServiceProvider.registerBeacon
protected function registerBeacon() { $this->app->singleton(BeaconContract::class, function ($app) { $config = $app['config']; return new Beacon($config); }); }
php
protected function registerBeacon() { $this->app->singleton(BeaconContract::class, function ($app) { $config = $app['config']; return new Beacon($config); }); }
[ "protected", "function", "registerBeacon", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "BeaconContract", "::", "class", ",", "function", "(", "$", "app", ")", "{", "$", "config", "=", "$", "app", "[", "'config'", "]", ";", "return", "new", "Beacon", "(", "$", "config", ")", ";", "}", ")", ";", "}" ]
Register the beacon class. @return void
[ "Register", "the", "beacon", "class", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Foundation/Providers/IntegrationServiceProvider.php#L54-L61
220,872
CachetHQ/Cachet
app/Foundation/Providers/IntegrationServiceProvider.php
IntegrationServiceProvider.registerCredits
protected function registerCredits() { $this->app->singleton(CreditsContract::class, function ($app) { $cache = $app['cache.store']; return new Credits($cache); }); }
php
protected function registerCredits() { $this->app->singleton(CreditsContract::class, function ($app) { $cache = $app['cache.store']; return new Credits($cache); }); }
[ "protected", "function", "registerCredits", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "CreditsContract", "::", "class", ",", "function", "(", "$", "app", ")", "{", "$", "cache", "=", "$", "app", "[", "'cache.store'", "]", ";", "return", "new", "Credits", "(", "$", "cache", ")", ";", "}", ")", ";", "}" ]
Register the credits class. @return void
[ "Register", "the", "credits", "class", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Foundation/Providers/IntegrationServiceProvider.php#L68-L75
220,873
CachetHQ/Cachet
app/Foundation/Providers/IntegrationServiceProvider.php
IntegrationServiceProvider.registerFeed
protected function registerFeed() { $this->app->singleton(FeedContract::class, function ($app) { $cache = $app['cache.store']; return new Feed($cache); }); }
php
protected function registerFeed() { $this->app->singleton(FeedContract::class, function ($app) { $cache = $app['cache.store']; return new Feed($cache); }); }
[ "protected", "function", "registerFeed", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "FeedContract", "::", "class", ",", "function", "(", "$", "app", ")", "{", "$", "cache", "=", "$", "app", "[", "'cache.store'", "]", ";", "return", "new", "Feed", "(", "$", "cache", ")", ";", "}", ")", ";", "}" ]
Register the feed class. @return void
[ "Register", "the", "feed", "class", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Foundation/Providers/IntegrationServiceProvider.php#L82-L89
220,874
CachetHQ/Cachet
app/Foundation/Providers/IntegrationServiceProvider.php
IntegrationServiceProvider.registerSystem
protected function registerSystem() { $this->app->singleton(SystemContract::class, function (Container $app) { $config = $app['config']; $auth = $app['auth.driver']; return new System($config, $auth); }); }
php
protected function registerSystem() { $this->app->singleton(SystemContract::class, function (Container $app) { $config = $app['config']; $auth = $app['auth.driver']; return new System($config, $auth); }); }
[ "protected", "function", "registerSystem", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "SystemContract", "::", "class", ",", "function", "(", "Container", "$", "app", ")", "{", "$", "config", "=", "$", "app", "[", "'config'", "]", ";", "$", "auth", "=", "$", "app", "[", "'auth.driver'", "]", ";", "return", "new", "System", "(", "$", "config", ",", "$", "auth", ")", ";", "}", ")", ";", "}" ]
Register the system class. @return void
[ "Register", "the", "system", "class", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Foundation/Providers/IntegrationServiceProvider.php#L96-L104
220,875
CachetHQ/Cachet
app/Foundation/Providers/IntegrationServiceProvider.php
IntegrationServiceProvider.registerReleases
protected function registerReleases() { $this->app->singleton(ReleasesContract::class, function ($app) { $cache = $app['cache.store']; $token = $app['config']->get('services.github.token'); return new Releases($cache, $token); }); }
php
protected function registerReleases() { $this->app->singleton(ReleasesContract::class, function ($app) { $cache = $app['cache.store']; $token = $app['config']->get('services.github.token'); return new Releases($cache, $token); }); }
[ "protected", "function", "registerReleases", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "ReleasesContract", "::", "class", ",", "function", "(", "$", "app", ")", "{", "$", "cache", "=", "$", "app", "[", "'cache.store'", "]", ";", "$", "token", "=", "$", "app", "[", "'config'", "]", "->", "get", "(", "'services.github.token'", ")", ";", "return", "new", "Releases", "(", "$", "cache", ",", "$", "token", ")", ";", "}", ")", ";", "}" ]
Register the releases class. @return void
[ "Register", "the", "releases", "class", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Foundation/Providers/IntegrationServiceProvider.php#L111-L119
220,876
CachetHQ/Cachet
app/Bus/Handlers/Commands/System/Config/UpdateConfigCommandHandler.php
UpdateConfigCommandHandler.handle
public function handle(UpdateConfigCommand $command) { foreach ($command->values as $setting => $value) { $this->writeEnv($setting, $value); } }
php
public function handle(UpdateConfigCommand $command) { foreach ($command->values as $setting => $value) { $this->writeEnv($setting, $value); } }
[ "public", "function", "handle", "(", "UpdateConfigCommand", "$", "command", ")", "{", "foreach", "(", "$", "command", "->", "values", "as", "$", "setting", "=>", "$", "value", ")", "{", "$", "this", "->", "writeEnv", "(", "$", "setting", ",", "$", "value", ")", ";", "}", "}" ]
Handle update config command handler instance. @param \CachetHQ\Cachet\Bus\Commands\System\Config\UpdateConfigCommand $command @return void
[ "Handle", "update", "config", "command", "handler", "instance", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/System/Config/UpdateConfigCommandHandler.php#L32-L37
220,877
CachetHQ/Cachet
app/Bus/Handlers/Commands/System/Config/UpdateConfigCommandHandler.php
UpdateConfigCommandHandler.writeEnv
protected function writeEnv($key, $value) { $dir = app()->environmentPath(); $file = app()->environmentFile(); $path = "{$dir}/{$file}"; try { (new Dotenv($dir, $file))->load(); $envKey = strtoupper($key); $envValue = env($envKey) ?: 'null'; file_put_contents($path, str_replace( "{$envKey}={$envValue}", "{$envKey}={$value}", file_get_contents($path) )); } catch (InvalidPathException $e) { throw $e; } }
php
protected function writeEnv($key, $value) { $dir = app()->environmentPath(); $file = app()->environmentFile(); $path = "{$dir}/{$file}"; try { (new Dotenv($dir, $file))->load(); $envKey = strtoupper($key); $envValue = env($envKey) ?: 'null'; file_put_contents($path, str_replace( "{$envKey}={$envValue}", "{$envKey}={$value}", file_get_contents($path) )); } catch (InvalidPathException $e) { throw $e; } }
[ "protected", "function", "writeEnv", "(", "$", "key", ",", "$", "value", ")", "{", "$", "dir", "=", "app", "(", ")", "->", "environmentPath", "(", ")", ";", "$", "file", "=", "app", "(", ")", "->", "environmentFile", "(", ")", ";", "$", "path", "=", "\"{$dir}/{$file}\"", ";", "try", "{", "(", "new", "Dotenv", "(", "$", "dir", ",", "$", "file", ")", ")", "->", "load", "(", ")", ";", "$", "envKey", "=", "strtoupper", "(", "$", "key", ")", ";", "$", "envValue", "=", "env", "(", "$", "envKey", ")", "?", ":", "'null'", ";", "file_put_contents", "(", "$", "path", ",", "str_replace", "(", "\"{$envKey}={$envValue}\"", ",", "\"{$envKey}={$value}\"", ",", "file_get_contents", "(", "$", "path", ")", ")", ")", ";", "}", "catch", "(", "InvalidPathException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
Writes to the .env file with given parameters. @param string $key @param mixed $value @return void
[ "Writes", "to", "the", ".", "env", "file", "with", "given", "parameters", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/System/Config/UpdateConfigCommandHandler.php#L47-L67
220,878
CachetHQ/Cachet
app/Models/MetricPoint.php
MetricPoint.setCreatedAtAttribute
public function setCreatedAtAttribute($createdAt) { if (!$createdAt) { return; } if (!$createdAt instanceof DateTime) { $createdAt = Carbon::parse($createdAt); } $timestamp = $createdAt->format('U'); $timestamp = 30 * round($timestamp / 30); $date = Carbon::createFromFormat('U', $timestamp)->toDateTimeString(); $this->attributes['created_at'] = $date; return $date; }
php
public function setCreatedAtAttribute($createdAt) { if (!$createdAt) { return; } if (!$createdAt instanceof DateTime) { $createdAt = Carbon::parse($createdAt); } $timestamp = $createdAt->format('U'); $timestamp = 30 * round($timestamp / 30); $date = Carbon::createFromFormat('U', $timestamp)->toDateTimeString(); $this->attributes['created_at'] = $date; return $date; }
[ "public", "function", "setCreatedAtAttribute", "(", "$", "createdAt", ")", "{", "if", "(", "!", "$", "createdAt", ")", "{", "return", ";", "}", "if", "(", "!", "$", "createdAt", "instanceof", "DateTime", ")", "{", "$", "createdAt", "=", "Carbon", "::", "parse", "(", "$", "createdAt", ")", ";", "}", "$", "timestamp", "=", "$", "createdAt", "->", "format", "(", "'U'", ")", ";", "$", "timestamp", "=", "30", "*", "round", "(", "$", "timestamp", "/", "30", ")", ";", "$", "date", "=", "Carbon", "::", "createFromFormat", "(", "'U'", ",", "$", "timestamp", ")", "->", "toDateTimeString", "(", ")", ";", "$", "this", "->", "attributes", "[", "'created_at'", "]", "=", "$", "date", ";", "return", "$", "date", ";", "}" ]
Round the created at value into intervals of 30 seconds. @param string $createdAt @return string|void
[ "Round", "the", "created", "at", "value", "into", "intervals", "of", "30", "seconds", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Models/MetricPoint.php#L110-L128
220,879
CachetHQ/Cachet
app/Http/Controllers/StatusPageController.php
StatusPageController.getMetrics
public function getMetrics(Metric $metric) { $type = Binput::get('filter', AutoPresenter::decorate($metric)->view_name); $metrics = app(MetricRepository::class); switch ($type) { case 'last_hour': $metricData = $metrics->listPointsLastHour($metric); break; case 'today': $metricData = $metrics->listPointsToday($metric); break; case 'week': $metricData = $metrics->listPointsForWeek($metric); break; case 'month': $metricData = $metrics->listPointsForMonth($metric); break; default: $metricData = []; } return $this->item([ 'metric' => $metric->toArray(), 'items' => $metricData, ]); }
php
public function getMetrics(Metric $metric) { $type = Binput::get('filter', AutoPresenter::decorate($metric)->view_name); $metrics = app(MetricRepository::class); switch ($type) { case 'last_hour': $metricData = $metrics->listPointsLastHour($metric); break; case 'today': $metricData = $metrics->listPointsToday($metric); break; case 'week': $metricData = $metrics->listPointsForWeek($metric); break; case 'month': $metricData = $metrics->listPointsForMonth($metric); break; default: $metricData = []; } return $this->item([ 'metric' => $metric->toArray(), 'items' => $metricData, ]); }
[ "public", "function", "getMetrics", "(", "Metric", "$", "metric", ")", "{", "$", "type", "=", "Binput", "::", "get", "(", "'filter'", ",", "AutoPresenter", "::", "decorate", "(", "$", "metric", ")", "->", "view_name", ")", ";", "$", "metrics", "=", "app", "(", "MetricRepository", "::", "class", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'last_hour'", ":", "$", "metricData", "=", "$", "metrics", "->", "listPointsLastHour", "(", "$", "metric", ")", ";", "break", ";", "case", "'today'", ":", "$", "metricData", "=", "$", "metrics", "->", "listPointsToday", "(", "$", "metric", ")", ";", "break", ";", "case", "'week'", ":", "$", "metricData", "=", "$", "metrics", "->", "listPointsForWeek", "(", "$", "metric", ")", ";", "break", ";", "case", "'month'", ":", "$", "metricData", "=", "$", "metrics", "->", "listPointsForMonth", "(", "$", "metric", ")", ";", "break", ";", "default", ":", "$", "metricData", "=", "[", "]", ";", "}", "return", "$", "this", "->", "item", "(", "[", "'metric'", "=>", "$", "metric", "->", "toArray", "(", ")", ",", "'items'", "=>", "$", "metricData", ",", "]", ")", ";", "}" ]
Returns metrics in a readily formatted way. @param \CachetHQ\Cachet\Models\Metric $metric @return \Illuminate\Http\JsonResponse
[ "Returns", "metrics", "in", "a", "readily", "formatted", "way", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/StatusPageController.php#L165-L182
220,880
CachetHQ/Cachet
app/Bus/Handlers/Commands/Component/RemoveComponentCommandHandler.php
RemoveComponentCommandHandler.handle
public function handle(RemoveComponentCommand $command) { $component = $command->component; event(new ComponentWasRemovedEvent($this->auth->user(), $component)); $component->delete(); }
php
public function handle(RemoveComponentCommand $command) { $component = $command->component; event(new ComponentWasRemovedEvent($this->auth->user(), $component)); $component->delete(); }
[ "public", "function", "handle", "(", "RemoveComponentCommand", "$", "command", ")", "{", "$", "component", "=", "$", "command", "->", "component", ";", "event", "(", "new", "ComponentWasRemovedEvent", "(", "$", "this", "->", "auth", "->", "user", "(", ")", ",", "$", "component", ")", ")", ";", "$", "component", "->", "delete", "(", ")", ";", "}" ]
Handle the remove component command. @param \CachetHQ\Cachet\Bus\Commands\Component\RemoveComponentCommand $command @return void
[ "Handle", "the", "remove", "component", "command", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Component/RemoveComponentCommandHandler.php#L46-L53
220,881
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ComponentController.php
ComponentController.showComponents
public function showComponents() { $components = Component::with('group')->orderBy('order')->orderBy('created_at')->get(); $this->subMenu['components']['active'] = true; return View::make('dashboard.components.index') ->withPageTitle(trans_choice('dashboard.components.components', 2).' - '.trans('dashboard.dashboard')) ->withComponents($components) ->withSubMenu($this->subMenu); }
php
public function showComponents() { $components = Component::with('group')->orderBy('order')->orderBy('created_at')->get(); $this->subMenu['components']['active'] = true; return View::make('dashboard.components.index') ->withPageTitle(trans_choice('dashboard.components.components', 2).' - '.trans('dashboard.dashboard')) ->withComponents($components) ->withSubMenu($this->subMenu); }
[ "public", "function", "showComponents", "(", ")", "{", "$", "components", "=", "Component", "::", "with", "(", "'group'", ")", "->", "orderBy", "(", "'order'", ")", "->", "orderBy", "(", "'created_at'", ")", "->", "get", "(", ")", ";", "$", "this", "->", "subMenu", "[", "'components'", "]", "[", "'active'", "]", "=", "true", ";", "return", "View", "::", "make", "(", "'dashboard.components.index'", ")", "->", "withPageTitle", "(", "trans_choice", "(", "'dashboard.components.components'", ",", "2", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withComponents", "(", "$", "components", ")", "->", "withSubMenu", "(", "$", "this", "->", "subMenu", ")", ";", "}" ]
Shows the components view. @return \Illuminate\View\View
[ "Shows", "the", "components", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ComponentController.php#L75-L85
220,882
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ComponentController.php
ComponentController.showEditComponent
public function showEditComponent(Component $component) { $groups = ComponentGroup::all(); $pageTitle = sprintf('"%s" - %s - %s', $component->name, trans('dashboard.components.edit.title'), trans('dashboard.dashboard')); return View::make('dashboard.components.edit') ->withPageTitle($pageTitle) ->withComponent($component) ->withGroups($groups); }
php
public function showEditComponent(Component $component) { $groups = ComponentGroup::all(); $pageTitle = sprintf('"%s" - %s - %s', $component->name, trans('dashboard.components.edit.title'), trans('dashboard.dashboard')); return View::make('dashboard.components.edit') ->withPageTitle($pageTitle) ->withComponent($component) ->withGroups($groups); }
[ "public", "function", "showEditComponent", "(", "Component", "$", "component", ")", "{", "$", "groups", "=", "ComponentGroup", "::", "all", "(", ")", ";", "$", "pageTitle", "=", "sprintf", "(", "'\"%s\" - %s - %s'", ",", "$", "component", "->", "name", ",", "trans", "(", "'dashboard.components.edit.title'", ")", ",", "trans", "(", "'dashboard.dashboard'", ")", ")", ";", "return", "View", "::", "make", "(", "'dashboard.components.edit'", ")", "->", "withPageTitle", "(", "$", "pageTitle", ")", "->", "withComponent", "(", "$", "component", ")", "->", "withGroups", "(", "$", "groups", ")", ";", "}" ]
Shows the edit component view. @param \CachetHQ\Cachet\Models\Component $component @return \Illuminate\View\View
[ "Shows", "the", "edit", "component", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ComponentController.php#L94-L104
220,883
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ComponentController.php
ComponentController.updateComponentAction
public function updateComponentAction(Component $component) { $componentData = Binput::get('component'); $tags = Arr::pull($componentData, 'tags'); try { $component = execute(new UpdateComponentCommand( $component, $componentData['name'], $componentData['description'], $componentData['status'], $componentData['link'], $componentData['order'], $componentData['group_id'], $componentData['enabled'], null, // Meta data cannot be supplied through the dashboard yet. true // Silent since we're not really making changes to the component (this should be optional) )); } catch (ValidationException $e) { return cachet_redirect('dashboard.components.edit', [$component->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure'))) ->withErrors($e->getMessageBag()); } $component->tags()->delete(); // The component was added successfully, so now let's deal with the tags. Collection::make(preg_split('/ ?, ?/', $tags))->map(function ($tag) { return trim($tag); })->map(function ($tag) { return execute(new CreateTagCommand($tag)); })->each(function ($tag) use ($component) { execute(new ApplyTagCommand($component, $tag)); }); return cachet_redirect('dashboard.components.edit', [$component->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.edit.success'))); }
php
public function updateComponentAction(Component $component) { $componentData = Binput::get('component'); $tags = Arr::pull($componentData, 'tags'); try { $component = execute(new UpdateComponentCommand( $component, $componentData['name'], $componentData['description'], $componentData['status'], $componentData['link'], $componentData['order'], $componentData['group_id'], $componentData['enabled'], null, // Meta data cannot be supplied through the dashboard yet. true // Silent since we're not really making changes to the component (this should be optional) )); } catch (ValidationException $e) { return cachet_redirect('dashboard.components.edit', [$component->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure'))) ->withErrors($e->getMessageBag()); } $component->tags()->delete(); // The component was added successfully, so now let's deal with the tags. Collection::make(preg_split('/ ?, ?/', $tags))->map(function ($tag) { return trim($tag); })->map(function ($tag) { return execute(new CreateTagCommand($tag)); })->each(function ($tag) use ($component) { execute(new ApplyTagCommand($component, $tag)); }); return cachet_redirect('dashboard.components.edit', [$component->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.edit.success'))); }
[ "public", "function", "updateComponentAction", "(", "Component", "$", "component", ")", "{", "$", "componentData", "=", "Binput", "::", "get", "(", "'component'", ")", ";", "$", "tags", "=", "Arr", "::", "pull", "(", "$", "componentData", ",", "'tags'", ")", ";", "try", "{", "$", "component", "=", "execute", "(", "new", "UpdateComponentCommand", "(", "$", "component", ",", "$", "componentData", "[", "'name'", "]", ",", "$", "componentData", "[", "'description'", "]", ",", "$", "componentData", "[", "'status'", "]", ",", "$", "componentData", "[", "'link'", "]", ",", "$", "componentData", "[", "'order'", "]", ",", "$", "componentData", "[", "'group_id'", "]", ",", "$", "componentData", "[", "'enabled'", "]", ",", "null", ",", "// Meta data cannot be supplied through the dashboard yet.", "true", "// Silent since we're not really making changes to the component (this should be optional)", ")", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "return", "cachet_redirect", "(", "'dashboard.components.edit'", ",", "[", "$", "component", "->", "id", "]", ")", "->", "withInput", "(", "Binput", "::", "all", "(", ")", ")", "->", "withTitle", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.whoops'", ")", ",", "trans", "(", "'dashboard.components.edit.failure'", ")", ")", ")", "->", "withErrors", "(", "$", "e", "->", "getMessageBag", "(", ")", ")", ";", "}", "$", "component", "->", "tags", "(", ")", "->", "delete", "(", ")", ";", "// The component was added successfully, so now let's deal with the tags.", "Collection", "::", "make", "(", "preg_split", "(", "'/ ?, ?/'", ",", "$", "tags", ")", ")", "->", "map", "(", "function", "(", "$", "tag", ")", "{", "return", "trim", "(", "$", "tag", ")", ";", "}", ")", "->", "map", "(", "function", "(", "$", "tag", ")", "{", "return", "execute", "(", "new", "CreateTagCommand", "(", "$", "tag", ")", ")", ";", "}", ")", "->", "each", "(", "function", "(", "$", "tag", ")", "use", "(", "$", "component", ")", "{", "execute", "(", "new", "ApplyTagCommand", "(", "$", "component", ",", "$", "tag", ")", ")", ";", "}", ")", ";", "return", "cachet_redirect", "(", "'dashboard.components.edit'", ",", "[", "$", "component", "->", "id", "]", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.components.edit.success'", ")", ")", ")", ";", "}" ]
Updates a component. @param \CachetHQ\Cachet\Models\Component $component @return \Illuminate\Http\RedirectResponse
[ "Updates", "a", "component", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ComponentController.php#L113-L151
220,884
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ComponentController.php
ComponentController.deleteComponentAction
public function deleteComponentAction(Component $component) { execute(new RemoveComponentCommand($component)); return cachet_redirect('dashboard.components') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success'))); }
php
public function deleteComponentAction(Component $component) { execute(new RemoveComponentCommand($component)); return cachet_redirect('dashboard.components') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success'))); }
[ "public", "function", "deleteComponentAction", "(", "Component", "$", "component", ")", "{", "execute", "(", "new", "RemoveComponentCommand", "(", "$", "component", ")", ")", ";", "return", "cachet_redirect", "(", "'dashboard.components'", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.components.delete.success'", ")", ")", ")", ";", "}" ]
Deletes a given component. @param \CachetHQ\Cachet\Models\Component $component @return \Illuminate\Http\RedirectResponse
[ "Deletes", "a", "given", "component", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ComponentController.php#L213-L219
220,885
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ScheduleController.php
ScheduleController.showIndex
public function showIndex() { $schedule = Schedule::orderBy('created_at')->get(); return View::make('dashboard.maintenance.index') ->withPageTitle(trans('dashboard.schedule.schedule').' - '.trans('dashboard.dashboard')) ->withSchedule($schedule); }
php
public function showIndex() { $schedule = Schedule::orderBy('created_at')->get(); return View::make('dashboard.maintenance.index') ->withPageTitle(trans('dashboard.schedule.schedule').' - '.trans('dashboard.dashboard')) ->withSchedule($schedule); }
[ "public", "function", "showIndex", "(", ")", "{", "$", "schedule", "=", "Schedule", "::", "orderBy", "(", "'created_at'", ")", "->", "get", "(", ")", ";", "return", "View", "::", "make", "(", "'dashboard.maintenance.index'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.schedule.schedule'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withSchedule", "(", "$", "schedule", ")", ";", "}" ]
Lists all scheduled maintenance. @return \Illuminate\View\View
[ "Lists", "all", "scheduled", "maintenance", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ScheduleController.php#L53-L60
220,886
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ScheduleController.php
ScheduleController.showAddSchedule
public function showAddSchedule() { $incidentTemplates = IncidentTemplate::all(); return View::make('dashboard.maintenance.add') ->withPageTitle(trans('dashboard.schedule.add.title').' - '.trans('dashboard.dashboard')) ->withIncidentTemplates($incidentTemplates); }
php
public function showAddSchedule() { $incidentTemplates = IncidentTemplate::all(); return View::make('dashboard.maintenance.add') ->withPageTitle(trans('dashboard.schedule.add.title').' - '.trans('dashboard.dashboard')) ->withIncidentTemplates($incidentTemplates); }
[ "public", "function", "showAddSchedule", "(", ")", "{", "$", "incidentTemplates", "=", "IncidentTemplate", "::", "all", "(", ")", ";", "return", "View", "::", "make", "(", "'dashboard.maintenance.add'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.schedule.add.title'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withIncidentTemplates", "(", "$", "incidentTemplates", ")", ";", "}" ]
Shows the add schedule maintenance form. @return \Illuminate\View\View
[ "Shows", "the", "add", "schedule", "maintenance", "form", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ScheduleController.php#L67-L74
220,887
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ScheduleController.php
ScheduleController.addScheduleAction
public function addScheduleAction() { try { execute(new CreateScheduleCommand( Binput::get('name'), Binput::get('message', null, false, false), Binput::get('status', Schedule::UPCOMING), Binput::get('scheduled_at'), Binput::get('completed_at'), Binput::get('components', []) )); } catch (ValidationException $e) { return cachet_redirect('dashboard.schedule.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.schedule') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.add.success'))); }
php
public function addScheduleAction() { try { execute(new CreateScheduleCommand( Binput::get('name'), Binput::get('message', null, false, false), Binput::get('status', Schedule::UPCOMING), Binput::get('scheduled_at'), Binput::get('completed_at'), Binput::get('components', []) )); } catch (ValidationException $e) { return cachet_redirect('dashboard.schedule.create') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.schedule') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.add.success'))); }
[ "public", "function", "addScheduleAction", "(", ")", "{", "try", "{", "execute", "(", "new", "CreateScheduleCommand", "(", "Binput", "::", "get", "(", "'name'", ")", ",", "Binput", "::", "get", "(", "'message'", ",", "null", ",", "false", ",", "false", ")", ",", "Binput", "::", "get", "(", "'status'", ",", "Schedule", "::", "UPCOMING", ")", ",", "Binput", "::", "get", "(", "'scheduled_at'", ")", ",", "Binput", "::", "get", "(", "'completed_at'", ")", ",", "Binput", "::", "get", "(", "'components'", ",", "[", "]", ")", ")", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "return", "cachet_redirect", "(", "'dashboard.schedule.create'", ")", "->", "withInput", "(", "Binput", "::", "all", "(", ")", ")", "->", "withTitle", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.whoops'", ")", ",", "trans", "(", "'dashboard.schedule.edit.failure'", ")", ")", ")", "->", "withErrors", "(", "$", "e", "->", "getMessageBag", "(", ")", ")", ";", "}", "return", "cachet_redirect", "(", "'dashboard.schedule'", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.schedule.add.success'", ")", ")", ")", ";", "}" ]
Creates a new scheduled maintenance. @return \Illuminate\Http\RedirectResponse
[ "Creates", "a", "new", "scheduled", "maintenance", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ScheduleController.php#L81-L101
220,888
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ScheduleController.php
ScheduleController.showEditSchedule
public function showEditSchedule(Schedule $schedule) { $incidentTemplates = IncidentTemplate::all(); return View::make('dashboard.maintenance.edit') ->withPageTitle(trans('dashboard.schedule.edit.title').' - '.trans('dashboard.dashboard')) ->withIncidentTemplates($incidentTemplates) ->withSchedule($schedule); }
php
public function showEditSchedule(Schedule $schedule) { $incidentTemplates = IncidentTemplate::all(); return View::make('dashboard.maintenance.edit') ->withPageTitle(trans('dashboard.schedule.edit.title').' - '.trans('dashboard.dashboard')) ->withIncidentTemplates($incidentTemplates) ->withSchedule($schedule); }
[ "public", "function", "showEditSchedule", "(", "Schedule", "$", "schedule", ")", "{", "$", "incidentTemplates", "=", "IncidentTemplate", "::", "all", "(", ")", ";", "return", "View", "::", "make", "(", "'dashboard.maintenance.edit'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.schedule.edit.title'", ")", ".", "' - '", ".", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withIncidentTemplates", "(", "$", "incidentTemplates", ")", "->", "withSchedule", "(", "$", "schedule", ")", ";", "}" ]
Shows the edit schedule maintenance form. @param \CachetHQ\Cachet\Models\Schedule $schedule @return \Illuminate\View\View
[ "Shows", "the", "edit", "schedule", "maintenance", "form", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ScheduleController.php#L110-L118
220,889
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ScheduleController.php
ScheduleController.editScheduleAction
public function editScheduleAction(Schedule $schedule) { try { $schedule = execute(new UpdateScheduleCommand( $schedule, Binput::get('name', null), Binput::get('message', null), Binput::get('status', null), Binput::get('scheduled_at', null), Binput::get('completed_at', null), Binput::get('components', []) )); } catch (ValidationException $e) { return cachet_redirect('dashboard.schedule.edit', [$schedule->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.schedule.edit', [$schedule->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.edit.success'))); }
php
public function editScheduleAction(Schedule $schedule) { try { $schedule = execute(new UpdateScheduleCommand( $schedule, Binput::get('name', null), Binput::get('message', null), Binput::get('status', null), Binput::get('scheduled_at', null), Binput::get('completed_at', null), Binput::get('components', []) )); } catch (ValidationException $e) { return cachet_redirect('dashboard.schedule.edit', [$schedule->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.schedule.edit', [$schedule->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.edit.success'))); }
[ "public", "function", "editScheduleAction", "(", "Schedule", "$", "schedule", ")", "{", "try", "{", "$", "schedule", "=", "execute", "(", "new", "UpdateScheduleCommand", "(", "$", "schedule", ",", "Binput", "::", "get", "(", "'name'", ",", "null", ")", ",", "Binput", "::", "get", "(", "'message'", ",", "null", ")", ",", "Binput", "::", "get", "(", "'status'", ",", "null", ")", ",", "Binput", "::", "get", "(", "'scheduled_at'", ",", "null", ")", ",", "Binput", "::", "get", "(", "'completed_at'", ",", "null", ")", ",", "Binput", "::", "get", "(", "'components'", ",", "[", "]", ")", ")", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "return", "cachet_redirect", "(", "'dashboard.schedule.edit'", ",", "[", "$", "schedule", "->", "id", "]", ")", "->", "withInput", "(", "Binput", "::", "all", "(", ")", ")", "->", "withTitle", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.whoops'", ")", ",", "trans", "(", "'dashboard.schedule.edit.failure'", ")", ")", ")", "->", "withErrors", "(", "$", "e", "->", "getMessageBag", "(", ")", ")", ";", "}", "return", "cachet_redirect", "(", "'dashboard.schedule.edit'", ",", "[", "$", "schedule", "->", "id", "]", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.schedule.edit.success'", ")", ")", ")", ";", "}" ]
Updates the given incident. @param \CachetHQ\Cachet\Models\Schedule $schedule @return \Illuminate\Http\RedirectResponse
[ "Updates", "the", "given", "incident", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ScheduleController.php#L127-L148
220,890
CachetHQ/Cachet
app/Http/Controllers/Dashboard/ScheduleController.php
ScheduleController.deleteScheduleAction
public function deleteScheduleAction(Schedule $schedule) { execute(new DeleteScheduleCommand($schedule)); return cachet_redirect('dashboard.schedule') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.delete.success'))); }
php
public function deleteScheduleAction(Schedule $schedule) { execute(new DeleteScheduleCommand($schedule)); return cachet_redirect('dashboard.schedule') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.delete.success'))); }
[ "public", "function", "deleteScheduleAction", "(", "Schedule", "$", "schedule", ")", "{", "execute", "(", "new", "DeleteScheduleCommand", "(", "$", "schedule", ")", ")", ";", "return", "cachet_redirect", "(", "'dashboard.schedule'", ")", "->", "withSuccess", "(", "sprintf", "(", "'%s %s'", ",", "trans", "(", "'dashboard.notifications.awesome'", ")", ",", "trans", "(", "'dashboard.schedule.delete.success'", ")", ")", ")", ";", "}" ]
Deletes a given schedule. @param \CachetHQ\Cachet\Models\Schedule $schedule @return \Illuminate\Http\RedirectResponse
[ "Deletes", "a", "given", "schedule", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/ScheduleController.php#L157-L163
220,891
CachetHQ/Cachet
app/Presenters/ComponentGroupPresenter.php
ComponentGroupPresenter.enabled_components_lowest
public function enabled_components_lowest() { if (is_bool($this->enabledComponentsLowest)) { $this->enabledComponentsLowest = $this->wrappedObject->enabled_components_lowest()->first(); } return $this->enabledComponentsLowest; }
php
public function enabled_components_lowest() { if (is_bool($this->enabledComponentsLowest)) { $this->enabledComponentsLowest = $this->wrappedObject->enabled_components_lowest()->first(); } return $this->enabledComponentsLowest; }
[ "public", "function", "enabled_components_lowest", "(", ")", "{", "if", "(", "is_bool", "(", "$", "this", "->", "enabledComponentsLowest", ")", ")", "{", "$", "this", "->", "enabledComponentsLowest", "=", "$", "this", "->", "wrappedObject", "->", "enabled_components_lowest", "(", ")", "->", "first", "(", ")", ";", "}", "return", "$", "this", "->", "enabledComponentsLowest", ";", "}" ]
Return the enabled components from the wrapped object, and cache it if need be. @return bool
[ "Return", "the", "enabled", "components", "from", "the", "wrapped", "object", "and", "cache", "it", "if", "need", "be", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Presenters/ComponentGroupPresenter.php#L71-L78
220,892
CachetHQ/Cachet
app/Presenters/ComponentGroupPresenter.php
ComponentGroupPresenter.is_collapsed
public function is_collapsed() { if ($this->wrappedObject->collapsed === 0) { return false; } elseif ($this->wrappedObject->collapsed === 1) { return true; } return $this->wrappedObject->components->filter(function ($component) { return $component->status > 1; })->isEmpty(); }
php
public function is_collapsed() { if ($this->wrappedObject->collapsed === 0) { return false; } elseif ($this->wrappedObject->collapsed === 1) { return true; } return $this->wrappedObject->components->filter(function ($component) { return $component->status > 1; })->isEmpty(); }
[ "public", "function", "is_collapsed", "(", ")", "{", "if", "(", "$", "this", "->", "wrappedObject", "->", "collapsed", "===", "0", ")", "{", "return", "false", ";", "}", "elseif", "(", "$", "this", "->", "wrappedObject", "->", "collapsed", "===", "1", ")", "{", "return", "true", ";", "}", "return", "$", "this", "->", "wrappedObject", "->", "components", "->", "filter", "(", "function", "(", "$", "component", ")", "{", "return", "$", "component", "->", "status", ">", "1", ";", "}", ")", "->", "isEmpty", "(", ")", ";", "}" ]
Determine if the group should be collapsed. @return bool
[ "Determine", "if", "the", "group", "should", "be", "collapsed", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Presenters/ComponentGroupPresenter.php#L95-L106
220,893
CachetHQ/Cachet
app/Presenters/ComponentGroupPresenter.php
ComponentGroupPresenter.has_subscriber
public function has_subscriber($subscriptions) { $enabled_components = $this->wrappedObject->enabled_components()->orderBy('order')->pluck('id')->toArray(); $intersected = array_intersect($enabled_components, $subscriptions); return count($intersected) != 0; }
php
public function has_subscriber($subscriptions) { $enabled_components = $this->wrappedObject->enabled_components()->orderBy('order')->pluck('id')->toArray(); $intersected = array_intersect($enabled_components, $subscriptions); return count($intersected) != 0; }
[ "public", "function", "has_subscriber", "(", "$", "subscriptions", ")", "{", "$", "enabled_components", "=", "$", "this", "->", "wrappedObject", "->", "enabled_components", "(", ")", "->", "orderBy", "(", "'order'", ")", "->", "pluck", "(", "'id'", ")", "->", "toArray", "(", ")", ";", "$", "intersected", "=", "array_intersect", "(", "$", "enabled_components", ",", "$", "subscriptions", ")", ";", "return", "count", "(", "$", "intersected", ")", "!=", "0", ";", "}" ]
Determine if any of the contained components have active subscriptions. @return bool
[ "Determine", "if", "any", "of", "the", "contained", "components", "have", "active", "subscriptions", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Presenters/ComponentGroupPresenter.php#L127-L133
220,894
CachetHQ/Cachet
app/Bus/Handlers/Commands/Metric/RemoveMetricPointCommandHandler.php
RemoveMetricPointCommandHandler.handle
public function handle(RemoveMetricPointCommand $command) { $metricPoint = $command->metricPoint; event(new MetricPointWasRemovedEvent($this->auth->user(), $metricPoint)); $metricPoint->delete(); }
php
public function handle(RemoveMetricPointCommand $command) { $metricPoint = $command->metricPoint; event(new MetricPointWasRemovedEvent($this->auth->user(), $metricPoint)); $metricPoint->delete(); }
[ "public", "function", "handle", "(", "RemoveMetricPointCommand", "$", "command", ")", "{", "$", "metricPoint", "=", "$", "command", "->", "metricPoint", ";", "event", "(", "new", "MetricPointWasRemovedEvent", "(", "$", "this", "->", "auth", "->", "user", "(", ")", ",", "$", "metricPoint", ")", ")", ";", "$", "metricPoint", "->", "delete", "(", ")", ";", "}" ]
Handle the remove metric point command. @param \CachetHQ\Cachet\Bus\Commands\Metric\RemoveMetricPointCommand $command @return void
[ "Handle", "the", "remove", "metric", "point", "command", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Metric/RemoveMetricPointCommandHandler.php#L47-L54
220,895
CachetHQ/Cachet
app/Models/Component.php
Component.scopeAuthenticated
public function scopeAuthenticated(Builder $query, $authenticated) { return $query->when(!$authenticated, function (Builder $query) { return $query->whereDoesntHave('group', function (Builder $query) { $query->where('visible', ComponentGroup::VISIBLE_AUTHENTICATED); }); }); }
php
public function scopeAuthenticated(Builder $query, $authenticated) { return $query->when(!$authenticated, function (Builder $query) { return $query->whereDoesntHave('group', function (Builder $query) { $query->where('visible', ComponentGroup::VISIBLE_AUTHENTICATED); }); }); }
[ "public", "function", "scopeAuthenticated", "(", "Builder", "$", "query", ",", "$", "authenticated", ")", "{", "return", "$", "query", "->", "when", "(", "!", "$", "authenticated", ",", "function", "(", "Builder", "$", "query", ")", "{", "return", "$", "query", "->", "whereDoesntHave", "(", "'group'", ",", "function", "(", "Builder", "$", "query", ")", "{", "$", "query", "->", "where", "(", "'visible'", ",", "ComponentGroup", "::", "VISIBLE_AUTHENTICATED", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Find all components which are within visible groups. @param \Illuminate\Database\Eloquent\Builder $query @param bool $authenticated @return \Illuminate\Database\Eloquent\Builder
[ "Find", "all", "components", "which", "are", "within", "visible", "groups", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Models/Component.php#L189-L196
220,896
CachetHQ/Cachet
app/Http/Controllers/Dashboard/DashboardController.php
DashboardController.showDashboard
public function showDashboard() { $components = Component::orderBy('order')->get(); $incidents = $this->getIncidents(); $subscribers = $this->getSubscribers(); $componentGroups = $this->getVisibleGroupedComponents(); $ungroupedComponents = Component::ungrouped()->get(); $welcomeUser = !Auth::user()->welcomed; if ($welcomeUser) { execute(new WelcomeUserCommand(Auth::user())); } $entries = null; if ($feed = $this->feed->latest()) { if (is_object($feed)) { $entries = array_slice($feed->channel->item, 0, 5); } } return View::make('dashboard.index') ->withPageTitle(trans('dashboard.dashboard')) ->withComponents($components) ->withIncidents($incidents) ->withSubscribers($subscribers) ->withEntries($entries) ->withComponentGroups($componentGroups) ->withUngroupedComponents($ungroupedComponents) ->withWelcomeUser($welcomeUser); }
php
public function showDashboard() { $components = Component::orderBy('order')->get(); $incidents = $this->getIncidents(); $subscribers = $this->getSubscribers(); $componentGroups = $this->getVisibleGroupedComponents(); $ungroupedComponents = Component::ungrouped()->get(); $welcomeUser = !Auth::user()->welcomed; if ($welcomeUser) { execute(new WelcomeUserCommand(Auth::user())); } $entries = null; if ($feed = $this->feed->latest()) { if (is_object($feed)) { $entries = array_slice($feed->channel->item, 0, 5); } } return View::make('dashboard.index') ->withPageTitle(trans('dashboard.dashboard')) ->withComponents($components) ->withIncidents($incidents) ->withSubscribers($subscribers) ->withEntries($entries) ->withComponentGroups($componentGroups) ->withUngroupedComponents($ungroupedComponents) ->withWelcomeUser($welcomeUser); }
[ "public", "function", "showDashboard", "(", ")", "{", "$", "components", "=", "Component", "::", "orderBy", "(", "'order'", ")", "->", "get", "(", ")", ";", "$", "incidents", "=", "$", "this", "->", "getIncidents", "(", ")", ";", "$", "subscribers", "=", "$", "this", "->", "getSubscribers", "(", ")", ";", "$", "componentGroups", "=", "$", "this", "->", "getVisibleGroupedComponents", "(", ")", ";", "$", "ungroupedComponents", "=", "Component", "::", "ungrouped", "(", ")", "->", "get", "(", ")", ";", "$", "welcomeUser", "=", "!", "Auth", "::", "user", "(", ")", "->", "welcomed", ";", "if", "(", "$", "welcomeUser", ")", "{", "execute", "(", "new", "WelcomeUserCommand", "(", "Auth", "::", "user", "(", ")", ")", ")", ";", "}", "$", "entries", "=", "null", ";", "if", "(", "$", "feed", "=", "$", "this", "->", "feed", "->", "latest", "(", ")", ")", "{", "if", "(", "is_object", "(", "$", "feed", ")", ")", "{", "$", "entries", "=", "array_slice", "(", "$", "feed", "->", "channel", "->", "item", ",", "0", ",", "5", ")", ";", "}", "}", "return", "View", "::", "make", "(", "'dashboard.index'", ")", "->", "withPageTitle", "(", "trans", "(", "'dashboard.dashboard'", ")", ")", "->", "withComponents", "(", "$", "components", ")", "->", "withIncidents", "(", "$", "incidents", ")", "->", "withSubscribers", "(", "$", "subscribers", ")", "->", "withEntries", "(", "$", "entries", ")", "->", "withComponentGroups", "(", "$", "componentGroups", ")", "->", "withUngroupedComponents", "(", "$", "ungroupedComponents", ")", "->", "withWelcomeUser", "(", "$", "welcomeUser", ")", ";", "}" ]
Shows the dashboard view. @return \Illuminate\View\View
[ "Shows", "the", "dashboard", "view", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/DashboardController.php#L93-L123
220,897
CachetHQ/Cachet
app/Http/Controllers/Dashboard/DashboardController.php
DashboardController.getIncidents
protected function getIncidents() { $allIncidents = Incident::whereBetween('occurred_at', [ $this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00', $this->startDate->format('Y-m-d').' 23:59:59', ])->orderBy('occurred_at', 'desc')->get()->groupBy(function (Incident $incident) { return (new Date($incident->occurred_at)) ->setTimezone($this->dateTimeZone)->toDateString(); }); // Add in days that have no incidents foreach (range(0, 30) as $i) { $date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i); if (!isset($allIncidents[$date->toDateString()])) { $allIncidents[$date->toDateString()] = []; } } // Sort the array so it takes into account the added days $allIncidents = $allIncidents->sortBy(function ($value, $key) { return strtotime($key); }, SORT_REGULAR, false); return $allIncidents; }
php
protected function getIncidents() { $allIncidents = Incident::whereBetween('occurred_at', [ $this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00', $this->startDate->format('Y-m-d').' 23:59:59', ])->orderBy('occurred_at', 'desc')->get()->groupBy(function (Incident $incident) { return (new Date($incident->occurred_at)) ->setTimezone($this->dateTimeZone)->toDateString(); }); // Add in days that have no incidents foreach (range(0, 30) as $i) { $date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i); if (!isset($allIncidents[$date->toDateString()])) { $allIncidents[$date->toDateString()] = []; } } // Sort the array so it takes into account the added days $allIncidents = $allIncidents->sortBy(function ($value, $key) { return strtotime($key); }, SORT_REGULAR, false); return $allIncidents; }
[ "protected", "function", "getIncidents", "(", ")", "{", "$", "allIncidents", "=", "Incident", "::", "whereBetween", "(", "'occurred_at'", ",", "[", "$", "this", "->", "startDate", "->", "copy", "(", ")", "->", "subDays", "(", "30", ")", "->", "format", "(", "'Y-m-d'", ")", ".", "' 00:00:00'", ",", "$", "this", "->", "startDate", "->", "format", "(", "'Y-m-d'", ")", ".", "' 23:59:59'", ",", "]", ")", "->", "orderBy", "(", "'occurred_at'", ",", "'desc'", ")", "->", "get", "(", ")", "->", "groupBy", "(", "function", "(", "Incident", "$", "incident", ")", "{", "return", "(", "new", "Date", "(", "$", "incident", "->", "occurred_at", ")", ")", "->", "setTimezone", "(", "$", "this", "->", "dateTimeZone", ")", "->", "toDateString", "(", ")", ";", "}", ")", ";", "// Add in days that have no incidents", "foreach", "(", "range", "(", "0", ",", "30", ")", "as", "$", "i", ")", "{", "$", "date", "=", "(", "new", "Date", "(", "$", "this", "->", "startDate", ")", ")", "->", "setTimezone", "(", "$", "this", "->", "dateTimeZone", ")", "->", "subDays", "(", "$", "i", ")", ";", "if", "(", "!", "isset", "(", "$", "allIncidents", "[", "$", "date", "->", "toDateString", "(", ")", "]", ")", ")", "{", "$", "allIncidents", "[", "$", "date", "->", "toDateString", "(", ")", "]", "=", "[", "]", ";", "}", "}", "// Sort the array so it takes into account the added days", "$", "allIncidents", "=", "$", "allIncidents", "->", "sortBy", "(", "function", "(", "$", "value", ",", "$", "key", ")", "{", "return", "strtotime", "(", "$", "key", ")", ";", "}", ",", "SORT_REGULAR", ",", "false", ")", ";", "return", "$", "allIncidents", ";", "}" ]
Fetches all of the incidents over the last 30 days. @return \Illuminate\Support\Collection
[ "Fetches", "all", "of", "the", "incidents", "over", "the", "last", "30", "days", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/DashboardController.php#L130-L155
220,898
CachetHQ/Cachet
app/Http/Controllers/Dashboard/DashboardController.php
DashboardController.getSubscribers
protected function getSubscribers() { $allSubscribers = Subscriber::whereBetween('created_at', [ $this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00', $this->startDate->format('Y-m-d').' 23:59:59', ])->orderBy('created_at', 'desc')->get()->groupBy(function (Subscriber $incident) { return (new Date($incident->created_at)) ->setTimezone($this->dateTimeZone)->toDateString(); }); // Add in days that have no incidents foreach (range(0, 30) as $i) { $date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i); if (!isset($allSubscribers[$date->toDateString()])) { $allSubscribers[$date->toDateString()] = []; } } // Sort the array so it takes into account the added days $allSubscribers = $allSubscribers->sortBy(function ($value, $key) { return strtotime($key); }, SORT_REGULAR, false); return $allSubscribers; }
php
protected function getSubscribers() { $allSubscribers = Subscriber::whereBetween('created_at', [ $this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00', $this->startDate->format('Y-m-d').' 23:59:59', ])->orderBy('created_at', 'desc')->get()->groupBy(function (Subscriber $incident) { return (new Date($incident->created_at)) ->setTimezone($this->dateTimeZone)->toDateString(); }); // Add in days that have no incidents foreach (range(0, 30) as $i) { $date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i); if (!isset($allSubscribers[$date->toDateString()])) { $allSubscribers[$date->toDateString()] = []; } } // Sort the array so it takes into account the added days $allSubscribers = $allSubscribers->sortBy(function ($value, $key) { return strtotime($key); }, SORT_REGULAR, false); return $allSubscribers; }
[ "protected", "function", "getSubscribers", "(", ")", "{", "$", "allSubscribers", "=", "Subscriber", "::", "whereBetween", "(", "'created_at'", ",", "[", "$", "this", "->", "startDate", "->", "copy", "(", ")", "->", "subDays", "(", "30", ")", "->", "format", "(", "'Y-m-d'", ")", ".", "' 00:00:00'", ",", "$", "this", "->", "startDate", "->", "format", "(", "'Y-m-d'", ")", ".", "' 23:59:59'", ",", "]", ")", "->", "orderBy", "(", "'created_at'", ",", "'desc'", ")", "->", "get", "(", ")", "->", "groupBy", "(", "function", "(", "Subscriber", "$", "incident", ")", "{", "return", "(", "new", "Date", "(", "$", "incident", "->", "created_at", ")", ")", "->", "setTimezone", "(", "$", "this", "->", "dateTimeZone", ")", "->", "toDateString", "(", ")", ";", "}", ")", ";", "// Add in days that have no incidents", "foreach", "(", "range", "(", "0", ",", "30", ")", "as", "$", "i", ")", "{", "$", "date", "=", "(", "new", "Date", "(", "$", "this", "->", "startDate", ")", ")", "->", "setTimezone", "(", "$", "this", "->", "dateTimeZone", ")", "->", "subDays", "(", "$", "i", ")", ";", "if", "(", "!", "isset", "(", "$", "allSubscribers", "[", "$", "date", "->", "toDateString", "(", ")", "]", ")", ")", "{", "$", "allSubscribers", "[", "$", "date", "->", "toDateString", "(", ")", "]", "=", "[", "]", ";", "}", "}", "// Sort the array so it takes into account the added days", "$", "allSubscribers", "=", "$", "allSubscribers", "->", "sortBy", "(", "function", "(", "$", "value", ",", "$", "key", ")", "{", "return", "strtotime", "(", "$", "key", ")", ";", "}", ",", "SORT_REGULAR", ",", "false", ")", ";", "return", "$", "allSubscribers", ";", "}" ]
Fetches all of the subscribers over the last 30 days. @return \Illuminate\Support\Collection
[ "Fetches", "all", "of", "the", "subscribers", "over", "the", "last", "30", "days", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/DashboardController.php#L162-L187
220,899
CachetHQ/Cachet
app/Models/Traits/SearchableTrait.php
SearchableTrait.scopeSearch
public function scopeSearch(Builder $query, array $search = []) { if (empty($search)) { return $query; } if (!array_intersect(array_keys($search), $this->searchable)) { return $query; } return $query->where($search); }
php
public function scopeSearch(Builder $query, array $search = []) { if (empty($search)) { return $query; } if (!array_intersect(array_keys($search), $this->searchable)) { return $query; } return $query->where($search); }
[ "public", "function", "scopeSearch", "(", "Builder", "$", "query", ",", "array", "$", "search", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "search", ")", ")", "{", "return", "$", "query", ";", "}", "if", "(", "!", "array_intersect", "(", "array_keys", "(", "$", "search", ")", ",", "$", "this", "->", "searchable", ")", ")", "{", "return", "$", "query", ";", "}", "return", "$", "query", "->", "where", "(", "$", "search", ")", ";", "}" ]
Adds a search scope. @param \Illuminate\Database\Eloquent\Builder $query @param array $search @return \Illuminate\Database\Eloquent\Builder
[ "Adds", "a", "search", "scope", "." ]
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Models/Traits/SearchableTrait.php#L31-L42