From a80275c1ace747cf5b746cc7059bde588794f23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Thu, 24 Oct 2019 18:59:21 +0200 Subject: [PATCH] findBy\* ForwardsCalls --- src/TenantManager.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/TenantManager.php b/src/TenantManager.php index d1f0d743..6fe6c661 100644 --- a/src/TenantManager.php +++ b/src/TenantManager.php @@ -7,6 +7,7 @@ namespace Stancl\Tenancy; use Illuminate\Contracts\Console\Kernel as ConsoleKernel; use Illuminate\Foundation\Application; use Illuminate\Support\Collection; +use Illuminate\Support\Traits\ForwardsCalls; use Stancl\Tenancy\Contracts\TenantCannotBeCreatedException; use Stancl\Tenancy\Exceptions\NotImplementedException; use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedException; @@ -18,6 +19,8 @@ use Stancl\Tenancy\Jobs\QueuedTenantDatabaseSeeder; */ class TenantManager { + use ForwardsCalls; + /** * The current tenant. * @@ -426,4 +429,13 @@ class TenantManager return $prevented; }, []); } + + public function __call($method, $parameters) + { + if (Str::startsWith($method, 'findBy')) { + return $this->findBy(Str::snake(substr($method, 6)), $parameters[0]); + } + + static::throwBadMethodCallException($method); + } }