sarga/packages/Webkul/Cart/src/Providers/CartServiceProvider.php

59 lines
1.4 KiB
PHP
Raw Normal View History

2018-09-06 06:20:30 +00:00
<?php
namespace Webkul\Cart\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
2018-09-06 06:20:30 +00:00
use Illuminate\Routing\Router;
use Illuminate\Foundation\AliasLoader;
2018-09-10 09:31:34 +00:00
use Webkul\User\Http\Middleware\RedirectIfNotAdmin;
use Webkul\Customer\Http\Middleware\RedirectIfNotCustomer;
use Webkul\Cart\Facades\Cart;
2018-09-19 07:00:24 +00:00
use Webkul\Cart\Providers\ComposerServiceProvider;
2018-09-06 06:20:30 +00:00
class CartServiceProvider extends ServiceProvider
{
2018-09-06 06:20:30 +00:00
public function boot(Router $router)
{
2018-09-10 09:31:34 +00:00
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
2018-09-06 06:20:30 +00:00
2018-09-10 09:31:34 +00:00
$router->aliasMiddleware('admin', RedirectIfNotAdmin::class);
2018-09-06 06:20:30 +00:00
2018-09-19 07:00:24 +00:00
$router->aliasMiddleware('customer', RedirectIfNotCustomer::class);
2018-09-11 11:19:40 +00:00
2018-09-19 07:00:24 +00:00
$this->app->register(ComposerServiceProvider::class);
2018-09-06 06:20:30 +00:00
}
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->registerFacades();
}
/**
* Register Bouncer as a singleton.
*
* @return void
*/
protected function registerFacades()
{
2018-09-19 07:00:24 +00:00
//to make the cart facade and bind the
//alias to the class needed to be called.
$loader = AliasLoader::getInstance();
$loader->alias('cart', Cart::class);
$this->app->singleton('cart', function () {
return new cart();
});
$this->app->bind('cart', 'Webkul\Cart\Cart');
2018-09-06 06:20:30 +00:00
}
}