-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathCartManagerServiceProvider.php
59 lines (49 loc) · 1.88 KB
/
CartManagerServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Freshbitsweb\LaravelCartManager;
use Illuminate\Support\ServiceProvider;
use Freshbitsweb\LaravelCartManager\Core\Cart;
use Freshbitsweb\LaravelCartManager\Contracts\CartDriver;
use Freshbitsweb\LaravelCartManager\Observers\CartObserver;
use Freshbitsweb\LaravelCartManager\Contracts\Cart as CartContract;
use Freshbitsweb\LaravelCartManager\Console\Commands\ClearCartDataCommand;
class CartManagerServiceProvider extends ServiceProvider
{
/**
* Publishes configuration file and registers error handler for Slack notification.
*
* @return void
*/
public function boot()
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/../config/cart_manager.php' => config_path('cart_manager.php'),
], 'laravel-cart-manager-config');
$this->publishes([
__DIR__.'/../database/migrations/' => database_path('migrations'),
], 'laravel-cart-manager-migrations');
$this->commands([ClearCartDataCommand::class]);
}
resolve(config('cart_manager.cart_model'))::observe(CartObserver::class);
}
/**
* Service container bindings.
*
* @return void
*/
public function register()
{
// Users can specify only the options they actually want to override
$this->mergeConfigFrom(
__DIR__.'/../config/cart_manager.php', 'cart_manager'
);
// Bind the driver with contract
$this->app->bind(CartDriver::class, $this->app['config']['cart_manager']['driver']);
// Bind the custom cart model with contract
$this->app->bind(CartContract::class, $this->app['config']['cart_manager']['cart_model']);
// Bind the cart class
$this->app->bind(Cart::class, function ($app) {
return new Cart($app->make(CartDriver::class));
});
}
}