mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Merge pull request #10103 from snipe/fixes/make_boolean_fields_nullable
Fixed issue when creating a status label via API - default_label and show_in_nav being not nullable
This commit is contained in:
commit
d88c0ae5ec
|
@ -74,7 +74,7 @@ class StatuslabelsController extends Controller
|
||||||
$statuslabel->archived = $statusType['archived'];
|
$statuslabel->archived = $statusType['archived'];
|
||||||
$statuslabel->color = $request->input('color');
|
$statuslabel->color = $request->input('color');
|
||||||
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
|
$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()) {
|
if ($statuslabel->save()) {
|
||||||
|
@ -127,8 +127,8 @@ class StatuslabelsController extends Controller
|
||||||
$statuslabel->pending = $statusType['pending'];
|
$statuslabel->pending = $statusType['pending'];
|
||||||
$statuslabel->archived = $statusType['archived'];
|
$statuslabel->archived = $statusType['archived'];
|
||||||
$statuslabel->color = $request->input('color');
|
$statuslabel->color = $request->input('color');
|
||||||
$statuslabel->show_in_nav = $request->input('show_in_nav');
|
$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()) {
|
if ($statuslabel->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $statuslabel, trans('admin/statuslabels/message.update.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $statuslabel, trans('admin/statuslabels/message.update.success')));
|
||||||
|
|
|
@ -13,7 +13,7 @@ class AddShowInNavToStatusLabels extends Migration
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::table('status_labels', function (Blueprint $table) {
|
Schema::table('status_labels', function (Blueprint $table) {
|
||||||
$table->boolean('show_in_nav')->default(0);
|
$table->boolean('show_in_nav')->nullable()->default(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class AddDefaultFlagOnStatuslabels extends Migration
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::table('status_labels', function (Blueprint $table) {
|
Schema::table('status_labels', function (Blueprint $table) {
|
||||||
$table->boolean('default_label')->default(0);
|
$table->boolean('default_label')->nullable()->default(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use App\Models\Statuslabel;
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
Statuslabel::whereNull('default_label')
|
||||||
|
->update(['default_label' => 0]);
|
||||||
|
|
||||||
|
Statuslabel::whereNull('show_in_nav')
|
||||||
|
->update(['show_in_nav' => 0]);
|
||||||
|
|
||||||
|
|
||||||
|
Schema::table('status_labels', function (Blueprint $table) {
|
||||||
|
$table->boolean('default_label')->nullable()->default(0)->change();
|
||||||
|
$table->boolean('show_in_nav')->nullable()->default(0)->change();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue