From 1afa36e8e9cfa76813840f76f339305d72074e06 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Fri, 15 Mar 2019 00:03:54 +0800 Subject: [PATCH] Apply fixes from StyleCI (#18) [skip ci] This pull request applies code style fixes from an analysis carried out by [StyleCI](https://github.styleci.io). --- For more information, click [here](https://github.styleci.io/analyses/zYNYDd). --- app/Console/Commands/MigrateCloset.php | 3 ++- app/Http/Controllers/ClosetController.php | 2 ++ app/Http/Controllers/SkinlibController.php | 1 + app/Models/User.php | 1 + tests/SkinlibControllerTest.php | 4 ++-- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/MigrateCloset.php b/app/Console/Commands/MigrateCloset.php index 170ca20f..37c2f695 100644 --- a/app/Console/Commands/MigrateCloset.php +++ b/app/Console/Commands/MigrateCloset.php @@ -40,8 +40,9 @@ class MigrateCloset extends Command */ public function handle() { - if (!Schema::hasTable('closets')) { + if (! Schema::hasTable('closets')) { $this->info('Nothing to do.'); + return; } diff --git a/app/Http/Controllers/ClosetController.php b/app/Http/Controllers/ClosetController.php index a5eddd3a..ea56056b 100644 --- a/app/Http/Controllers/ClosetController.php +++ b/app/Http/Controllers/ClosetController.php @@ -45,6 +45,7 @@ class ClosetController extends Controller // Pagination $items = $closet->get()->map(function ($t) { $t->name = $t->pivot->item_name; + return $t; }); $totalPages = ceil($items->count() / $perPage); @@ -98,6 +99,7 @@ class ClosetController extends Controller } $user->closet()->updateExistingPivot($request->tid, ['item_name' => $request->new_name]); + return json(trans('user.closet.rename.success', ['name' => $request->new_name]), 0); } diff --git a/app/Http/Controllers/SkinlibController.php b/app/Http/Controllers/SkinlibController.php index 3dfd79eb..a3edd1ec 100644 --- a/app/Http/Controllers/SkinlibController.php +++ b/app/Http/Controllers/SkinlibController.php @@ -211,6 +211,7 @@ class SkinlibController extends Controller $user->setScore($cost, 'minus'); $user->closet()->attach($t->tid, ['item_name' => $t->name]); + return json(trans('skinlib.upload.success', ['name' => $request->input('name')]), 0, [ 'tid' => $t->tid, ]); diff --git a/app/Models/User.php b/app/Models/User.php index 93d03806..159971b4 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -318,6 +318,7 @@ class User extends Authenticatable public function delete() { Player::where('uid', $this->uid)->delete(); + return parent::delete(); } diff --git a/tests/SkinlibControllerTest.php b/tests/SkinlibControllerTest.php index 6b7bdaae..4d700c44 100644 --- a/tests/SkinlibControllerTest.php +++ b/tests/SkinlibControllerTest.php @@ -272,7 +272,7 @@ class SkinlibControllerTest extends TestCase ]) ->decodeResponseJson('items'); $this->assertTrue(collect($items)->every(function ($item) { - return !$item['liked']; + return ! $item['liked']; })); // A user has added a texture from skin library to his closet @@ -281,7 +281,7 @@ class SkinlibControllerTest extends TestCase $this->getJson('/skinlib/data') ->assertJson([ 'items' => [ - ['tid' => $texture->tid, 'liked' => true] + ['tid' => $texture->tid, 'liked' => true], ], 'current_uid' => $otherUser->uid, 'total_pages' => 2,