Skip to content

Commit 05d26ba

Browse files
committed
Forward mailbox calls to the mailbox manager
1 parent adaee3f commit 05d26ba

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/MailboxServiceProvider.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Support\Facades\Route;
66
use BeyondCode\Mailbox\Routing\Router;
77
use Illuminate\Support\ServiceProvider;
8+
use BeyondCode\Mailbox\Facades\Mailbox;
89
use BeyondCode\Mailbox\Http\Middleware\MailboxBasicAuthentication;
910

1011
class MailboxServiceProvider extends ServiceProvider
@@ -43,10 +44,14 @@ public function register()
4344
$this->app->singleton('mailbox', function () {
4445
return new Router($this->app);
4546
});
47+
48+
$this->app->singleton(MailboxManager::class, function () {
49+
return new MailboxManager($this->app);
50+
});
4651
}
4752

4853
protected function registerDriver()
4954
{
50-
(new MailboxManager($this->app))->mailbox()->register();
55+
Mailbox::mailbox()->register();
5156
}
5257
}

src/Routing/Router.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

33
namespace BeyondCode\Mailbox\Routing;
44

5+
use BeyondCode\Mailbox\MailboxManager;
56
use Illuminate\Support\Collection;
67
use Illuminate\Container\Container;
78
use BeyondCode\Mailbox\InboundEmail;
9+
use Illuminate\Support\Traits\ForwardsCalls;
810

911
class Router
1012
{
13+
use ForwardsCalls;
14+
1115
/** @var RouteCollection */
1216
protected $routes;
1317

@@ -109,4 +113,11 @@ protected function storeEmail(InboundEmail $email)
109113
{
110114
$email->save();
111115
}
116+
117+
public function __call($method, $parameters)
118+
{
119+
return $this->forwardCallTo(
120+
$this->container->make(MailboxManager::class), $method, $parameters
121+
);
122+
}
112123
}

0 commit comments

Comments
 (0)