diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index df498da8c..78693b60c 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -334,7 +334,11 @@ class Helper '#92896B', ]; + $total_colors = count($colors); + if ($index >= $total_colors) { + $index = $index - $total_colors; + } return $colors[$index]; } diff --git a/app/Http/Controllers/AssetModelsController.php b/app/Http/Controllers/AssetModelsController.php index 54d2310e8..dbefb2e7b 100755 --- a/app/Http/Controllers/AssetModelsController.php +++ b/app/Http/Controllers/AssetModelsController.php @@ -82,8 +82,8 @@ class AssetModelsController extends Controller $model->user_id = Auth::id(); $model->requestable = Request::has('requestable'); - if ($request->input('custom_fieldset') != '') { - $model->fieldset_id = e($request->input('custom_fieldset')); + if ($request->input('fieldset_id') != '') { + $model->fieldset_id = e($request->input('fieldset_id')); } $model = $request->handleImages($model); @@ -160,10 +160,10 @@ class AssetModelsController extends Controller $this->removeCustomFieldsDefaultValues($model); - if ($request->input('custom_fieldset') == '') { + if ($request->input('fieldset_id') == '') { $model->fieldset_id = null; } else { - $model->fieldset_id = $request->input('custom_fieldset'); + $model->fieldset_id = $request->input('fieldset_id'); if ($this->shouldAddDefaultValues($request->input())) { if (!$this->assignCustomFieldsDefaultValues($model, $request->input('default_values'))){ @@ -444,7 +444,7 @@ class AssetModelsController extends Controller { return ! empty($input['add_default_values']) && ! empty($input['default_values']) - && ! empty($input['custom_fieldset']); + && ! empty($input['fieldset_id']); } /** diff --git a/database/migrations/2021_04_14_180125_add_ids_to_tables.php b/database/migrations/2021_04_14_180125_add_ids_to_tables.php index 07172164f..bac56466c 100644 --- a/database/migrations/2021_04_14_180125_add_ids_to_tables.php +++ b/database/migrations/2021_04_14_180125_add_ids_to_tables.php @@ -22,7 +22,7 @@ class AddIdsToTables extends Migration Schema::table('password_resets', function (Blueprint $table) { // Add the id column to the password_resets table if it doesn't yet have one - if (! Schema::hasColumn('password_resets', 'id')) { + if (! Schema::hasColumn('password_resets', 'id') && $this->notUsingSqlite()) { $table->increments('id'); } }); @@ -47,4 +47,9 @@ class AddIdsToTables extends Migration } }); } + + private function notUsingSqlite() + { + return Schema::connection($this->getConnection())->getConnection()->getDriverName() !== 'sqlite'; + } } diff --git a/database/migrations/2023_02_28_173527_adds_webhook_option_to_settings_table.php b/database/migrations/2023_02_28_173527_adds_webhook_option_to_settings_table.php index c3409c9d6..269a62518 100644 --- a/database/migrations/2023_02_28_173527_adds_webhook_option_to_settings_table.php +++ b/database/migrations/2023_02_28_173527_adds_webhook_option_to_settings_table.php @@ -13,12 +13,27 @@ class AddsWebhookOptionToSettingsTable extends Migration */ public function up() { + /** + * So...you're probably wondering why this isn't all in one Schema::table()... + * Turns out we'll get the following error: + * "SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification." + * if we're running sqlite so a solution is to make multiple calls. + * ¯\_(ツ)_/¯ + */ Schema::table('settings', function (Blueprint $table) { - $table->string('webhook_selected')->after('slack_botname')->default('slack')->nullable(); - $table->renameColumn('slack_botname', 'webhook_botname'); - $table->renameColumn('slack_endpoint', 'webhook_endpoint'); - $table->renameColumn('slack_channel', 'webhook_channel'); + $table->string('webhook_selected')->after('slack_botname')->default('slack')->nullable(); + }); + Schema::table('settings', function (Blueprint $table) { + $table->renameColumn('slack_botname', 'webhook_botname'); + }); + + Schema::table('settings', function (Blueprint $table) { + $table->renameColumn('slack_endpoint', 'webhook_endpoint'); + }); + + Schema::table('settings', function (Blueprint $table) { + $table->renameColumn('slack_channel', 'webhook_channel'); }); } diff --git a/resources/views/notifications/markdown/report-expiring-assets.blade.php b/resources/views/notifications/markdown/report-expiring-assets.blade.php index 4311096a6..7c91fff97 100644 --- a/resources/views/notifications/markdown/report-expiring-assets.blade.php +++ b/resources/views/notifications/markdown/report-expiring-assets.blade.php @@ -10,7 +10,7 @@ $expires = Helper::getFormattedDateObject($asset->present()->warranty_expires, ' $diff = round(abs(strtotime($asset->present()->warranty_expires) - strtotime(date('Y-m-d')))/86400); $icon = ($diff <= ($threshold / 2)) ? '🚨' : (($diff <= $threshold) ? '⚠️' : ' '); @endphp -