From 9686ef672f239085c489ad960d5c70d18199be45 Mon Sep 17 00:00:00 2001 From: Yuriy Martini Date: Tue, 22 Jan 2019 15:01:23 +0100 Subject: [PATCH 1/2] [FIX] updated to be compatible with Laravel's Custom Polymorphic Types. see: https://laravel.com/docs/5.7/eloquent-relationships#custom-polymorphic-types --- src/CanComment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CanComment.php b/src/CanComment.php index 325663b..f42fd26 100644 --- a/src/CanComment.php +++ b/src/CanComment.php @@ -18,7 +18,7 @@ public function comment(Commentable $commentable, string $commentText = '', int 'rate' => $commentable->canBeRated() ? $rate : null, 'approved' => $commentable->mustBeApproved() && !$this->canCommentWithoutApprove() ? false : true, 'commented_id' => $this->primaryId(), - 'commented_type' => get_class(), + 'commented_type' => $this->getMorphClass(), ]); $commentable->comments()->save($comment); @@ -41,7 +41,7 @@ public function hasCommentsOn(Commentable $commentable): bool return $this->comments() ->where([ 'commentable_id' => $commentable->primaryId(), - 'commentable_type' => get_class($commentable), + 'commentable_type' => $commentable->getMorphClass(), ]) ->exists(); } From 94ce39a02f56e5c1fd25cd5d4151dfbb28db0682 Mon Sep 17 00:00:00 2001 From: actuallymab Date: Tue, 5 Mar 2019 12:17:16 +0100 Subject: [PATCH 2/2] Laravel 5.8 Support (cherry picked from commit 965279cb3fd4a171a5ab6bbe17c5cecfeff39de2) --- .scrutinizer.yml | 2 +- composer.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index f235dc0..4e48850 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -28,4 +28,4 @@ checks: tools: external_code_coverage: timeout: 600 - runs: 2 + runs: 1 diff --git a/composer.json b/composer.json index f1ffb9b..fcb9162 100644 --- a/composer.json +++ b/composer.json @@ -16,11 +16,11 @@ ], "require": { "php": "^7.1.3", - "illuminate/database": "~5.5.0|~5.6.0|~5.7.0" + "illuminate/database": "~5.5.0|~5.6.0|~5.7.0|~5.8.0" }, "require-dev": { "phpunit/phpunit": "^7.4", - "orchestra/testbench": "~3.5.0|~3.6.0|~3.7.0", + "orchestra/testbench": "~3.5.0|~3.6.0|~3.7.0|~3.8.0", "fzaninotto/faker": "^1.8", "scrutinizer/ocular": "^1.5" },