Skip to content

Commit 19dfff0

Browse files
author
sanjingshou
committed
add facade
1 parent ad1677a commit 19dfff0

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Facade.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
namespace Observer\LaravelPdd;
3+
4+
use Illuminate\Support\Facades\Facade as LaravelFacade;
5+
6+
class Facade extends LaravelFacade
7+
{
8+
/**
9+
* @return string
10+
*/
11+
public static function getFacadeAccessor()
12+
{
13+
return 'easy.pdd';
14+
}
15+
}

src/ServiceProvider.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Observer\LaravelPdd;
33

44
use EasyPdd\Foundation\Application;
5+
use Illuminate\Foundation\Application as LaravelApplication;
56
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
67

78

@@ -12,15 +13,21 @@ class ServiceProvider extends LaravelServiceProvider
1213
*/
1314
public function boot()
1415
{
16+
$source = realpath(__DIR__.'/config.php');
1517

18+
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
19+
$this->publishes([$source => config_path('pdd.php')], 'laravel-pdd');
20+
}
21+
22+
$this->mergeConfigFrom($source, 'pdd');
1623
}
1724

1825
/**
1926
* Register the provider.
2027
*/
2128
public function register()
2229
{
23-
$this->app->singleton(Application::class, function ($laravelApp) {
30+
$this->app->singleton('easy.pdd', function ($laravelApp) {
2431
$app = new Application(config('pdd'));
2532
return $app;
2633
});

0 commit comments

Comments
 (0)