1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DavideCasiraghi\LaravelEventsCalendar; |
4
|
|
|
|
5
|
|
|
use Carbon\Carbon; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
|
8
|
|
|
class LaravelEventsCalendarServiceProvider extends ServiceProvider |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Bootstrap the application services. |
12
|
|
|
*/ |
13
|
|
|
public function boot() |
14
|
|
|
{ |
15
|
|
|
/* |
16
|
|
|
* Optional methods to load your package assets |
17
|
|
|
*/ |
18
|
|
|
// $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-events-calendar'); |
19
|
|
|
// $this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-events-calendar'); |
20
|
|
|
// $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
21
|
|
|
// $this->loadRoutesFrom(__DIR__.'/routes.php'); |
22
|
|
|
|
23
|
|
|
if ($this->app->runningInConsole()) { |
24
|
|
|
$this->publishes([ |
25
|
|
|
__DIR__.'/../config/config.php' => config_path('laravel-events-calendar.php'), |
26
|
|
|
], 'config'); |
27
|
|
|
|
28
|
|
|
// Publishing the views. |
29
|
|
|
/*$this->publishes([ |
30
|
|
|
__DIR__.'/../resources/views' => resource_path('views/vendor/laravel-events-calendar'), |
31
|
|
|
], 'views');*/ |
32
|
|
|
|
33
|
|
|
// Publishing assets. |
34
|
|
|
/*$this->publishes([ |
35
|
|
|
__DIR__.'/../resources/assets' => public_path('vendor/laravel-events-calendar'), |
36
|
|
|
], 'assets');*/ |
37
|
|
|
|
38
|
|
|
// Publishing the translation files. |
39
|
|
|
/*$this->publishes([ |
40
|
|
|
__DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-events-calendar'), |
41
|
|
|
], 'lang');*/ |
42
|
|
|
|
43
|
|
|
// Registering package commands. |
44
|
|
|
// $this->commands([]); |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
/* - Migrations - |
48
|
|
|
create a migration instance for each .php.stub file eg. |
49
|
|
|
create_continents_table.php.stub ---> 2019_04_28_190434761474_create_continents_table.php |
50
|
|
|
*/ |
51
|
|
|
$migrations = [ |
52
|
|
|
'CreateQuotesTable' => 'create_continents_table', |
53
|
|
|
'CreateCountriesTable' => 'create_countries_table', |
54
|
|
|
'CreateEventHasOrganizersTable' => 'create_event_has_organizers_table', |
55
|
|
|
'CreateEventHasTeachersTable' => 'create_event_has_teachers_table', |
56
|
|
|
'CreateEventsTable' => 'create_events_table', |
57
|
|
|
'CreateOrganizersTable' => 'create_organizers_table', |
58
|
|
|
'CreateEventCategoriesTable' => 'event_categories_table', |
59
|
|
|
'CreateEventRepetitionsTable' => 'event_repetitions_table', |
60
|
|
|
'CreateEventVenuesTable' => 'event_venues', |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
foreach ($migrations as $migrationFunctionName => $migrationFileName) { |
64
|
|
|
if (! class_exists($migrationFunctionName)) { |
65
|
|
|
$this->publishes([ |
66
|
|
|
__DIR__.'/../database/migrations/'.$migrationFileName.'.php.stub' => database_path('migrations/'.Carbon::now()->format('Y_m_d_Hmsu').'_'.$migrationFileName.'.php'), |
|
|
|
|
67
|
|
|
], 'migrations'); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Register the application services. |
77
|
|
|
*/ |
78
|
|
|
public function register() |
79
|
|
|
{ |
80
|
|
|
// Automatically apply the package configuration |
81
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'laravel-events-calendar'); |
82
|
|
|
|
83
|
|
|
// Register the main class to use with the facade |
84
|
|
|
$this->app->singleton('laravel-events-calendar', function () { |
85
|
|
|
return new LaravelEventsCalendar; |
86
|
|
|
}); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
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: