diff --git a/config/asseco-comments.php b/config/asseco-comments.php index 6610ce1..3cfcdff 100644 --- a/config/asseco-comments.php +++ b/config/asseco-comments.php @@ -17,7 +17,7 @@ /** * UUIDs as primary keys. */ - 'uuid' => false, + 'uuid' => false, /** * Timestamp types. @@ -30,11 +30,11 @@ * Should the package run the migrations. Set to false if you're publishing * and changing default migrations. */ - 'run' => true, + 'run' => true, ], 'routes' => [ - 'prefix' => 'api', + 'prefix' => 'api', 'middleware' => ['api'], ], ]; diff --git a/src/App/Http/Requests/CommentRequest.php b/src/App/Http/Requests/CommentRequest.php index e5b2c25..c451ead 100644 --- a/src/App/Http/Requests/CommentRequest.php +++ b/src/App/Http/Requests/CommentRequest.php @@ -27,9 +27,9 @@ public function authorize() public function rules() { return [ - 'body' => 'required', + 'body' => 'required', 'commentable_type' => 'required|string', - 'commentable_id' => 'required', + 'commentable_id' => 'required', ]; } diff --git a/src/Database/Factories/CommentFactory.php b/src/Database/Factories/CommentFactory.php index 857c424..443b696 100644 --- a/src/Database/Factories/CommentFactory.php +++ b/src/Database/Factories/CommentFactory.php @@ -20,15 +20,18 @@ public function modelName() */ public function definition() { + $commType = env('ASEE_COMMENTABLE_TYPE', $this->faker->word); + $data = [ - 'body' => $this->faker->sentence(), - 'commentable_type' => 'App\\Random\\' . ucfirst($this->faker->word), - 'commentable_id' => $this->faker->randomNumber(), + 'body' => $this->faker->sentence(), + //'commentable_type' => 'App\\Random\\' . ucfirst($this->faker->word), + 'commentable_type' => $commType, + 'commentable_id' => $this->faker->randomNumber(), ]; if (config('asseco-comments.migrations.uuid')) { $data = array_merge($data, [ - 'commentable_id' => $this->faker->uuid(), + 'commentable_id' => $this->faker->uuid(), ]); } diff --git a/tests/Feature/Http/Controllers/CommentControllerTest.php b/tests/Feature/Http/Controllers/CommentControllerTest.php index 6cee017..194e397 100644 --- a/tests/Feature/Http/Controllers/CommentControllerTest.php +++ b/tests/Feature/Http/Controllers/CommentControllerTest.php @@ -42,7 +42,7 @@ public function creates_comment() $this ->postJson(route('comments.store'), $request) ->assertJsonFragment([ - 'id' => 1, + 'id' => 1, 'body' => $request['body'], ]);