27 lines
782 B
PHP
27 lines
782 B
PHP
<?php
|
|
|
|
namespace Modules\Core\Providers;
|
|
|
|
use Illuminate\Support\Facades\Event;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Modules\Core\Auth\Events\UserAuthenticated;
|
|
use Modules\Core\Wishlist\Listeners\MergeGuestWishlistOnLogin;
|
|
use Modules\Core\Wishlist\Services\WishlistService;
|
|
|
|
class WishlistServiceProvider extends ServiceProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
// One instance per request: it caches the guest cookie's ids, so a
|
|
// toggle and a later has() in the same request agree.
|
|
$this->app->scoped(WishlistService::class);
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
$this->loadRoutesFrom(__DIR__.'/../Wishlist/routes/web.php');
|
|
|
|
Event::listen(UserAuthenticated::class, MergeGuestWishlistOnLogin::class);
|
|
}
|
|
}
|