From 3b7558388504bce20e4a4a52679468cba05718bc Mon Sep 17 00:00:00 2001 From: Torkil Johnsen Date: Thu, 27 Oct 2016 10:24:52 +0200 Subject: [PATCH 1/3] Fix compatibility with ModelNotFoundException The signature of ModelNotFoundException was changed in Laravel recently. --- src/Exceptions/ModelNotFoundForTenantException.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Exceptions/ModelNotFoundForTenantException.php b/src/Exceptions/ModelNotFoundForTenantException.php index 9855326..5344920 100644 --- a/src/Exceptions/ModelNotFoundForTenantException.php +++ b/src/Exceptions/ModelNotFoundForTenantException.php @@ -8,12 +8,13 @@ class ModelNotFoundForTenantException extends ModelNotFoundException implements { /** * @param string $model + * @param int|array $ids * * @return $this */ - public function setModel($model) + public function setModel($model, $ids = []) { - parent::setModel($model); + parent::setModel($model, $ids); $this->message = "No query results for model [{$model}] when scoped by tenant."; From d38af965084e5866b40584ef66e5d06b81c080cc Mon Sep 17 00:00:00 2001 From: Torkil Johnsen Date: Thu, 27 Oct 2016 10:29:07 +0200 Subject: [PATCH 2/3] Compatibility Make the class compatible with both the old and new version of `ModelNotFoundException`. --- src/Exceptions/ModelNotFoundForTenantException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Exceptions/ModelNotFoundForTenantException.php b/src/Exceptions/ModelNotFoundForTenantException.php index 5344920..43b8274 100644 --- a/src/Exceptions/ModelNotFoundForTenantException.php +++ b/src/Exceptions/ModelNotFoundForTenantException.php @@ -14,7 +14,7 @@ class ModelNotFoundForTenantException extends ModelNotFoundException implements */ public function setModel($model, $ids = []) { - parent::setModel($model, $ids); + parent::setModel($model); $this->message = "No query results for model [{$model}] when scoped by tenant."; From b8ebebd19e2fa7cef507fba0de94c6973c21917a Mon Sep 17 00:00:00 2001 From: Torkil Johnsen Date: Fri, 28 Oct 2016 11:02:56 +0200 Subject: [PATCH 3/3] Simplify; we don't need to call the parent Calling the parent is just unnecessary overhead in this case. --- src/Exceptions/ModelNotFoundForTenantException.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Exceptions/ModelNotFoundForTenantException.php b/src/Exceptions/ModelNotFoundForTenantException.php index 43b8274..cf709ed 100644 --- a/src/Exceptions/ModelNotFoundForTenantException.php +++ b/src/Exceptions/ModelNotFoundForTenantException.php @@ -14,8 +14,7 @@ class ModelNotFoundForTenantException extends ModelNotFoundException implements */ public function setModel($model, $ids = []) { - parent::setModel($model); - + $this->model = $model; $this->message = "No query results for model [{$model}] when scoped by tenant."; return $this;