Code fixes and a new migration

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2021-09-20 15:37:24 -07:00
parent 6772ace94e
commit b331bb33d9
4 changed files with 43 additions and 5 deletions

View file

@ -73,7 +73,7 @@ class StatuslabelsController extends Controller
$statuslabel->archived = $statusType['archived'];
$statuslabel->color = $request->input('color');
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
$statuslabel->default_label = $request->input('default_label');
$statuslabel->default_label = $request->input('default_label', 0);
if ($statuslabel->save()) {
@ -124,8 +124,8 @@ class StatuslabelsController extends Controller
$statuslabel->pending = $statusType['pending'];
$statuslabel->archived = $statusType['archived'];
$statuslabel->color = $request->input('color');
$statuslabel->show_in_nav = $request->input('show_in_nav');
$statuslabel->default_label = $request->input('default_label');
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
$statuslabel->default_label = $request->input('default_label', 0);
if ($statuslabel->save()) {
return response()->json(Helper::formatStandardApiResponse('success', $statuslabel, trans('admin/statuslabels/message.update.success')));

View file

@ -13,7 +13,7 @@ class AddShowInNavToStatusLabels extends Migration
public function up()
{
Schema::table('status_labels', function (Blueprint $table) {
$table->boolean('show_in_nav')->default(0);
$table->boolean('show_in_nav')->nullable()->default(0);
});
}

View file

@ -14,7 +14,7 @@ class AddDefaultFlagOnStatuslabels extends Migration
public function up()
{
Schema::table('status_labels', function (Blueprint $table) {
$table->boolean('default_label')->default(0);
$table->boolean('default_label')->nullable()->default(0);
});
}

View file

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ChangeDefaultLabelToNullable extends Migration
{
/**
* Run the migrations.
*
* This is stupid because it has a default valuye of 0 so it *should*
* default to 0, but it doesn't on some versions of MySQL.
*
* @return void
*/
public function up()
{
Schema::table('nullable', function (Blueprint $table) {
Schema::table('status_labels', function (Blueprint $table) {
$table->boolean('default_label')->nullable()->default(0);
$table->boolean('show_in_nav')->nullable()->default(0);
});
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('nullable', function (Blueprint $table) {
//
});
}
}