1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MadWeb\SocialAuth; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use MadWeb\SocialAuth\Console\CacheRefreshCommand; |
7
|
|
|
use MadWeb\SocialAuth\Console\AddSocialProviderCommand; |
8
|
|
|
|
9
|
|
|
class SocialAuthServiceProvider extends ServiceProvider |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Perform post-registration booting of services. |
13
|
|
|
* |
14
|
|
|
* @param SocialProvidersLoader $loader |
15
|
|
|
* @return void |
16
|
|
|
*/ |
17
|
57 |
|
public function boot(SocialProvidersLoader $loader) |
18
|
|
|
{ |
19
|
57 |
|
$this->registerResources(); |
20
|
|
|
|
21
|
|
|
// Share social Providers for views |
22
|
57 |
|
view()->composer(['social-auth::buttons', 'social-auth::attach'], function ($view) use ($loader) { |
|
|
|
|
23
|
|
|
/* @var \Illuminate\View\View $view */ |
24
|
|
|
$view->with('socialProviders', $loader->getSocialProviders()); |
25
|
57 |
|
}); |
26
|
|
|
|
27
|
57 |
|
$loader->registerSocialProviders(); |
28
|
|
|
|
29
|
57 |
|
$this->app->register(\SocialiteProviders\Manager\ServiceProvider::class); |
30
|
57 |
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Register any package services. |
34
|
|
|
* |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
57 |
|
public function register() |
38
|
|
|
{ |
39
|
57 |
|
$this->mergeConfigFrom( |
40
|
57 |
|
__DIR__.'/../config/social-auth.php', |
41
|
57 |
|
'social-auth' |
42
|
|
|
); |
43
|
|
|
|
44
|
57 |
|
$this->app->singleton('command.social-auth.refresh', CacheRefreshCommand::class); |
45
|
57 |
|
$this->app->singleton('command.social-auth.add', AddSocialProviderCommand::class); |
46
|
|
|
|
47
|
57 |
|
$this->commands(['command.social-auth.refresh', 'command.social-auth.add']); |
48
|
57 |
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Register package resources. |
52
|
|
|
*/ |
53
|
57 |
|
protected function registerResources() |
54
|
|
|
{ |
55
|
57 |
|
$resource_folder = __DIR__.'/../resources'; |
56
|
|
|
|
57
|
57 |
|
$this->publishes([ |
58
|
57 |
|
__DIR__.'/../config/social-auth.php' => $this->app->configPath().'/social-auth.php', |
59
|
57 |
|
], 'config'); |
60
|
|
|
|
61
|
57 |
|
if (! class_exists('CreateSocialProvidersTable')) { |
62
|
|
|
// Publish the migration |
63
|
3 |
|
$timestamp = date('Y_m_d_His', time()); |
64
|
3 |
|
$this->publishes([ |
65
|
3 |
|
__DIR__.'/../database/migrations/create_social_providers_table.php.stub' => $this->app->databasePath().'/migrations/'.$timestamp.'_create_social_providers_table.php', |
|
|
|
|
66
|
3 |
|
], 'migrations'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
// Views |
70
|
57 |
|
$this->loadViewsFrom($resource_folder.'/views', 'social-auth'); |
71
|
|
|
|
72
|
57 |
|
$this->publishes([ |
73
|
57 |
|
$resource_folder.'/views' => resource_path('views/vendor/social-auth'), |
74
|
57 |
|
], 'views'); |
75
|
|
|
|
76
|
|
|
// Translations |
77
|
57 |
|
$this->loadTranslationsFrom($resource_folder.'/lang', 'social-auth'); |
78
|
|
|
|
79
|
57 |
|
$this->publishes([ |
80
|
57 |
|
$resource_folder.'/lang' => resource_path('lang/vendor/social-auth'), |
81
|
57 |
|
], 'lang'); |
82
|
|
|
|
83
|
|
|
// Routes |
84
|
57 |
|
$this->loadRoutesFrom(__DIR__.'/../routes/routes.php'); |
85
|
57 |
|
} |
86
|
|
|
} |
87
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: