From be7d9b8a46dda41ee141157e0b353a36c7921d12 Mon Sep 17 00:00:00 2001 From: Hasin Hayder Date: Sat, 6 Aug 2022 15:20:49 +0600 Subject: [PATCH] Code formatting --- app/Exceptions/Handler.php | 8 ++++---- app/Http/Controllers/HydraController.php | 4 ++-- app/Http/Middleware/HydraLog.php | 4 ++-- database/seeders/UsersSeeder.php | 6 +++--- tests/Feature/AdminLoginTest.php | 8 ++++---- tests/Feature/RoleTest.php | 18 +++++++++--------- tests/Feature/UserTest.php | 6 +++--- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 5c8edbb..8c859d9 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -51,15 +51,15 @@ class Handler extends ExceptionHandler { public function render($request, Throwable $exception) { if ($exception instanceof ModelNotFoundException) { return response([ - 'error'=>1, - 'message'=>$exception->getMessage(), + 'error' => 1, + 'message' => $exception->getMessage(), ], 404); } if ($exception instanceof MissingAbilityException) { return response([ - 'error'=>1, - 'message'=>'Not authorized', + 'error' => 1, + 'message' => 'Not authorized', ], 409); } diff --git a/app/Http/Controllers/HydraController.php b/app/Http/Controllers/HydraController.php index 8459d79..e917b45 100644 --- a/app/Http/Controllers/HydraController.php +++ b/app/Http/Controllers/HydraController.php @@ -5,13 +5,13 @@ namespace App\Http\Controllers; class HydraController extends Controller { public function hydra() { return response([ - 'message'=>'Welcome to Hydra, the zero config API boilerplate with roles and abilities for Laravel Sanctum. Please visit https://hasinhayder.github.io/hydra to know more.', + 'message' => 'Welcome to Hydra, the zero config API boilerplate with roles and abilities for Laravel Sanctum. Please visit https://hasinhayder.github.io/hydra to know more.', ]); } public function version() { return response([ - 'version'=> config('hydra.version'), + 'version' => config('hydra.version'), ]); } } diff --git a/app/Http/Middleware/HydraLog.php b/app/Http/Middleware/HydraLog.php index dd18e0a..3d2f5cb 100644 --- a/app/Http/Middleware/HydraLog.php +++ b/app/Http/Middleware/HydraLog.php @@ -20,8 +20,8 @@ class HydraLog { public function terminate($request, $response) { Log::info("\n\n".str_repeat('=', 100)."\n\n"); - Log::debug('app.route', ['route'=>$request->route()]); - Log::debug('app.headers', ['headers'=>$request->headers]); + Log::debug('app.route', ['route' => $request->route()]); + Log::debug('app.headers', ['headers' => $request->headers]); Log::debug('app.requests', ['request' => $request->all()]); Log::debug('app.response', ['response' => $response]); Log::info("\n\n".str_repeat('=', 100)."\n\n"); diff --git a/database/seeders/UsersSeeder.php b/database/seeders/UsersSeeder.php index 167f87a..4ee48ea 100644 --- a/database/seeders/UsersSeeder.php +++ b/database/seeders/UsersSeeder.php @@ -21,9 +21,9 @@ class UsersSeeder extends Seeder { Schema::enableForeignKeyConstraints(); $user = User::create([ - 'email'=>'admin@hydra.project', - 'password'=>Hash::make('hydra'), - 'name'=>'Hydra Admin', + 'email' => 'admin@hydra.project', + 'password' => Hash::make('hydra'), + 'name' => 'Hydra Admin', ]); $user->roles()->attach(Role::where('slug', 'admin')->first()); } diff --git a/tests/Feature/AdminLoginTest.php b/tests/Feature/AdminLoginTest.php index 40da9bc..88a53b2 100644 --- a/tests/Feature/AdminLoginTest.php +++ b/tests/Feature/AdminLoginTest.php @@ -13,8 +13,8 @@ class AdminLoginTest extends TestCase { */ public function test_admin_login() { $response = $this->postJson('/api/login', [ - 'email'=>'admin@hydra.project', - 'password'=>'hydra', + 'email' => 'admin@hydra.project', + 'password' => 'hydra', ]); $response @@ -26,8 +26,8 @@ class AdminLoginTest extends TestCase { public function test_admin_login_fail() { $response = $this->postJson('/api/login', [ - 'email'=>'admin@hydra.project', - 'password'=>'hydrax', + 'email' => 'admin@hydra.project', + 'password' => 'hydrax', ]); $response diff --git a/tests/Feature/RoleTest.php b/tests/Feature/RoleTest.php index b56ee7e..eca31f8 100644 --- a/tests/Feature/RoleTest.php +++ b/tests/Feature/RoleTest.php @@ -49,7 +49,7 @@ class RoleTest extends TestCase { $response = $this->withHeader('Authorization', 'Bearer '.$this->token) ->put('/api/roles/4', [ - 'name'=>'Chief Editor', + 'name' => 'Chief Editor', ]); $response @@ -72,7 +72,7 @@ class RoleTest extends TestCase { $response = $this->withHeader('Authorization', 'Bearer '.$this->token) ->put('/api/roles/4', [ - 'slug'=>'chief-editor', + 'slug' => 'chief-editor', ]); $response @@ -95,8 +95,8 @@ class RoleTest extends TestCase { $response = $this->withHeader('Authorization', 'Bearer '.$this->token) ->put('/api/roles/4', [ - 'name'=>'Editor X', - 'slug'=>'editor-x', + 'name' => 'Editor X', + 'slug' => 'editor-x', ]); $response @@ -120,7 +120,7 @@ class RoleTest extends TestCase { $response = $this->withHeader('Authorization', 'Bearer '.$this->token) ->put('/api/roles/1', [ - 'slug'=>'admin-x', + 'slug' => 'admin-x', ]); $response @@ -143,8 +143,8 @@ class RoleTest extends TestCase { $response = $this->withHeader('Authorization', 'Bearer '.$this->token) ->post('/api/roles', [ - 'name'=>'New Role', - 'slug'=>'new-role', + 'name' => 'New Role', + 'slug' => 'new-role', ]); $response @@ -168,8 +168,8 @@ class RoleTest extends TestCase { $response = $this->withHeader('Authorization', 'Bearer '.$this->token) ->post('/api/roles', [ - 'name'=>'New Role', - 'slug'=>'new-role', + 'name' => 'New Role', + 'slug' => 'new-role', ]); $response diff --git a/tests/Feature/UserTest.php b/tests/Feature/UserTest.php index 0da9197..a0781fd 100644 --- a/tests/Feature/UserTest.php +++ b/tests/Feature/UserTest.php @@ -168,9 +168,9 @@ class UserTest extends TestCase { public function test_delete_admin_user_if_multiple_admins_are_present() { $newAdminUser = User::create([ - 'name'=>'Test Admin', - 'password'=>Hash::make('abcd'), - 'email'=>'testadmin@test.com', + 'name' => 'Test Admin', + 'password' => Hash::make('abcd'), + 'email' => 'testadmin@test.com', ]); $adminRole = Role::find(1);