Laravel 8.x Shift (#12235)

* Shift HTTP kernel and middleware

* Shift service providers

* Shift console routes

* Shift to class based factories

* Namespace seeders

* Shift PSR-4 autoloading

* Default config files

In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them. This allows you to review the commit
diff for once for customizations when you are done Shifting.

Moving forward, consider using ENV variables or create a separate
config file to allow the core config files to remain as default
as possible.

* Shift Laravel dependencies

* Shift return type of base TestCase methods

From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type:

- `setUpBeforeClass()`
- `setUp()`
- `assertPreConditions()`
- `assertPostConditions()`
- `tearDown()`
- `tearDownAfterClass()`
- `onNotSuccessfulTest()`

[1]: https://phpunit.de/announcements/phpunit-8.html

* Shift cleanup

* console routes

* composer update

* factories

* phpunit

* bootstrap pagination

* model factory

* wip

* Apply fixes from StyleCI (#12236)

* wip

* Apply fixes from StyleCI (#12238)

* wip

* wip

* wip

* wip

* Apply fixes from StyleCI (#12240)

* wip

* Apply fixes from StyleCI (#12242)

* composer update

* Bump to PHP 7.3 minimum

Co-authored-by: Laravel Shift <shift@laravelshift.com>
This commit is contained in:
Jellyfrog
2020-11-03 17:18:31 +01:00
committed by GitHub
parent bc02ab3f6e
commit 50c8033099
97 changed files with 2496 additions and 1604 deletions

View File

@@ -0,0 +1,20 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
$this->call(DefaultAlertTemplateSeeder::class);
$this->call(DefaultWidgetSeeder::class);
$this->call(DefaultLegacySchemaSeeder::class);
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class DefaultAlertTemplateSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$templates = [
[
'name' => 'BGP Sessions.',
'template' => '{{ $alert->title }}' . PHP_EOL . 'Severity: {{ $alert->severity }}' . PHP_EOL . '@if ($alert->state == 0) Time elapsed: {{ $alert->elapsed }} @endif' . PHP_EOL . 'Timestamp: {{ $alert->timestamp }}' . PHP_EOL . 'Unique-ID: {{ $alert->uid }}' . PHP_EOL . 'Rule: @if ($alert->name) {{ $alert->name }} @else {{ $alert->rule }} @endif' . PHP_EOL . '@if ($alert->faults) Faults:' . PHP_EOL . '@foreach ($alert->faults as $key => $value)' . PHP_EOL . ' #{{ $key }}: {{ $value[\'string\'] }}' . PHP_EOL . ' Peer: {{ $value[\'astext\'] }}' . PHP_EOL . ' Peer IP: {{ $value[\'bgpPeerIdentifier\'] }}' . PHP_EOL . ' Peer AS: {{ $value[\'bgpPeerRemoteAs\'] }}' . PHP_EOL . ' Peer EstTime: {{ $value[\'bgpPeerFsmEstablishedTime\'] }}' . PHP_EOL . ' Peer State: {{ $value[\'bgpPeerState\'] }}' . PHP_EOL . '@endforeach' . PHP_EOL . '@endif',
'title' => '',
'title_rec' => '',
],
[
'name' => 'Ports',
'template' => '{{ $alert->title }}' . PHP_EOL . 'Severity: {{ $alert->severity }}' . PHP_EOL . '@if ($alert->state == 0) Time elapsed: {{ $alert->elapsed }} @endif' . PHP_EOL . 'Timestamp: {{ $alert->timestamp }}' . PHP_EOL . 'Unique-ID: {{ $alert->uid }}' . PHP_EOL . 'Rule: @if ($alert->name) {{ $alert->name }} @else {{ $alert->rule }} @endif' . PHP_EOL . '@if ($alert->faults) Faults:' . PHP_EOL . '@foreach ($alert->faults as $key => $value)' . PHP_EOL . ' #{{ $key }}: {{ $value[\'string\'] }}' . PHP_EOL . ' Port: {{ $value[\'ifName\'] }}' . PHP_EOL . ' Port Name: {{ $value[\'ifAlias\'] }}' . PHP_EOL . ' Port Status: {{ $value[\'message\'] }}' . PHP_EOL . '@endforeach' . PHP_EOL . '@endif',
'title' => '',
'title_rec' => '',
],
[
'name' => 'Temperature',
'template' => '{{ $alert->title }}' . PHP_EOL . 'Severity: {{ $alert->severity }}' . PHP_EOL . '@if ($alert->state == 0) Time elapsed: {{ $alert->elapsed }} @endif' . PHP_EOL . 'Timestamp: {{ $alert->timestamp }}' . PHP_EOL . 'Unique-ID: {{ $alert->uid }}' . PHP_EOL . 'Rule: @if ($alert->name) {{ $alert->name }} @else {{ $alert->rule }} @endif' . PHP_EOL . '@if ($alert->faults) Faults:' . PHP_EOL . '@foreach ($alert->faults as $key => $value)' . PHP_EOL . ' #{{ $key }}: {{ $value[\'string\'] }}' . PHP_EOL . ' Temperature: {{ $value[\'sensor_current\'] }}' . PHP_EOL . ' Previous Measurement: {{ $value[\'sensor_prev\'] }}' . PHP_EOL . '@endforeach' . PHP_EOL . '@endif',
'title' => '',
'title_rec' => '',
],
[
'name' => 'Default Alert Template',
'template' => '{{ $alert->title }}' . PHP_EOL . 'Severity: {{ $alert->severity }}' . PHP_EOL . '@if ($alert->state == 0) Time elapsed: {{ $alert->elapsed }} @endif' . PHP_EOL . 'Timestamp: {{ $alert->timestamp }}' . PHP_EOL . 'Unique-ID: {{ $alert->uid }}' . PHP_EOL . 'Rule: @if ($alert->name) {{ $alert->name }} @else {{ $alert->rule }} @endif' . PHP_EOL . '@if ($alert->faults) Faults:' . PHP_EOL . '@foreach ($alert->faults as $key => $value)' . PHP_EOL . ' #{{ $key }}: {{ $value[\'string\'] }}' . PHP_EOL . '@endforeach' . PHP_EOL . '@endif' . PHP_EOL . 'Alert sent to:' . PHP_EOL . '@foreach ($alert->contacts as $key => $value)' . PHP_EOL . ' {{ $value }} <{{ $key }}>' . PHP_EOL . '@endforeach',
'title' => null,
'title_rec' => null,
],
];
$existing = DB::table('alert_templates')->pluck('name');
DB::table('alert_templates')->insert(array_filter($templates, function ($entry) use ($existing) {
return ! $existing->contains($entry['name']);
}));
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* DefaultLegacySchemaSeeder.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @link http://librenms.org
* @copyright 2018 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class DefaultLegacySchemaSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// insert version 1000 to prevent legacy schema code from running.
// additionally prevents seeder from being run again by build-base.php / includes/sql-schema/update.php.
if (! DB::table('dbSchema')->exists()) {
DB::table('dbSchema')->insert(['version' => 1000]);
}
}
}

View File

@@ -0,0 +1,116 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class DefaultWidgetSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$widgets = [
[
'widget_title' => 'Availability map',
'widget' => 'availability-map',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Device summary horizontal',
'widget' => 'device-summary-horiz',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Alerts',
'widget' => 'alerts',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Device summary vertical',
'widget' => 'device-summary-vert',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Globe map',
'widget' => 'globe',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Syslog',
'widget' => 'syslog',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Eventlog',
'widget' => 'eventlog',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'World map',
'widget' => 'worldmap',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Graylog',
'widget' => 'graylog',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Graph',
'widget' => 'generic-graph',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Top Devices',
'widget' => 'top-devices',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Top Interfaces',
'widget' => 'top-interfaces',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Notes',
'widget' => 'notes',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'External Images',
'widget' => 'generic-image',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Component Status',
'widget' => 'component-status',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Alert History Stats',
'widget' => 'alertlog-stats',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Server Stats',
'widget' => 'server-stats',
'base_dimensions' => '6,3',
],
[
'widget_title' => 'Alert History',
'widget' => 'alertlog',
'base_dimensions' => '6,3',
],
];
$existing = DB::table('widgets')->pluck('widget');
DB::table('widgets')->insert(array_filter($widgets, function ($entry) use ($existing) {
return ! $existing->contains($entry['widget']);
}));
}
}