From 3b62c4a83ad12e579727636250b6bbae29db0824 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 22 Feb 2019 13:20:42 -0800 Subject: [PATCH 1/3] Fixes/integrity constraint (#6754) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Migration to fix nullables This should fix an issue introduced in 90cddb7aeeca6ca3c471ca75ab8d5fd08ba47858 where we’re passing null instead of an empty string (necessary to nullify values via the API) * Removed asset migration - serial was already fixed --- ...703_make_fields_nullable_for_integrity.php | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 database/migrations/2019_02_21_224703_make_fields_nullable_for_integrity.php diff --git a/database/migrations/2019_02_21_224703_make_fields_nullable_for_integrity.php b/database/migrations/2019_02_21_224703_make_fields_nullable_for_integrity.php new file mode 100644 index 0000000000..b9811921f7 --- /dev/null +++ b/database/migrations/2019_02_21_224703_make_fields_nullable_for_integrity.php @@ -0,0 +1,64 @@ +string('city')->nullable()->default(null)->change(); + $table->string('state')->nullable()->default(null)->change(); + $table->string('country')->nullable()->default(null)->change(); + $table->integer('user_id')->nullable()->default(null)->change(); + $table->string('address')->nullable()->default(null)->change(); + $table->string('address2')->nullable()->default(null)->change(); + }); + + Schema::table('users', function (Blueprint $table) { + $table->string('last_name')->nullable()->default(null)->change(); + }); + + Schema::table('suppliers', function (Blueprint $table) { + $table->integer('user_id')->nullable()->default(null)->change(); + }); + + Schema::table('status_labels', function (Blueprint $table) { + $table->integer('user_id')->nullable()->default(null)->change(); + }); + + Schema::table('models', function (Blueprint $table) { + $table->integer('user_id')->nullable()->default(null)->change(); + $table->integer('manufacturer_id')->nullable()->default(null)->change(); + $table->integer('category_id')->nullable()->default(null)->change(); + }); + + Schema::table('licenses', function (Blueprint $table) { + $table->integer('user_id')->nullable()->default(null)->change(); + $table->boolean('maintained')->nullable()->default(null)->change(); + }); + + Schema::table('depreciations', function (Blueprint $table) { + $table->integer('user_id')->nullable()->default(null)->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} From 53db96edadd556aa75b37bd56261059a561c2234 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 22 Feb 2019 13:24:45 -0800 Subject: [PATCH 2/3] Bumped minor version --- config/version.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/version.php b/config/version.php index 3d1f1875b8..0e33b47f77 100644 --- a/config/version.php +++ b/config/version.php @@ -1,10 +1,10 @@ 'v4.6.12', - 'full_app_version' => 'v4.6.12 - build 3982-gd687e1d76', - 'build_version' => '3982', + 'app_version' => 'v4.6.13', + 'full_app_version' => 'v4.6.13 - build 3985-g5f3147cf3', + 'build_version' => '3985', 'prerelease_version' => '', - 'hash_version' => 'gd687e1d76', - 'full_hash' => 'v4.6.12-1-gd687e1d76', + 'hash_version' => 'g5f3147cf3', + 'full_hash' => 'v4.6.13-2-g5f3147cf3', 'branch' => 'master', ); From 348c13f318f4cc21169cfb9a13cce97112a8de97 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 1 Mar 2019 16:31:22 -0800 Subject: [PATCH 3/3] Add accessories endpoint to user API --- app/Http/Controllers/Api/UsersController.php | 18 ++++++++++++++++++ routes/api.php | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index cdf4d3be64..8783679b9b 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -12,6 +12,7 @@ use App\Http\Requests\SaveUserRequest; use App\Models\Asset; use App\Http\Transformers\AssetsTransformer; use App\Http\Transformers\SelectlistTransformer; +use App\Http\Transformers\AccessoriesTransformer; class UsersController extends Controller { @@ -302,6 +303,23 @@ class UsersController extends Controller return (new AssetsTransformer)->transformAssets($assets, $assets->count()); } + /** + * Return JSON containing a list of accessories assigned to a user. + * + * @author [A. Gianotto] [] + * @since [v4.6.14] + * @param $userId + * @return string JSON + */ + public function accessories($id) + { + $this->authorize('view', User::class); + $user = User::findOrFail($id); + $this->authorize('view', Accessory::class); + $accessories = $user->accessories; + return (new AccessoriesTransformer)->transformAccessories($accessories, $accessories->count()); + } + /** * Reset the user's two-factor status * diff --git a/routes/api.php b/routes/api.php index c66c388820..fffc46d55a 100644 --- a/routes/api.php +++ b/routes/api.php @@ -715,6 +715,13 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () { ] ); + Route::get('{user}/accessories', + [ + 'as' => 'api.users.accessorieslist', + 'uses' => 'UsersController@accessories' + ] + ); + Route::post('{user}/upload', [ 'as' => 'api.users.uploads',