-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTmdbServiceProvider.php
49 lines (44 loc) · 1.31 KB
/
TmdbServiceProvider.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
<?php
namespace Astrotomic\Tmdb;
use Astrotomic\Tmdb\Models\Collection;
use Astrotomic\Tmdb\Models\Credit;
use Astrotomic\Tmdb\Models\Movie;
use Astrotomic\Tmdb\Models\MovieGenre;
use Astrotomic\Tmdb\Models\Person;
use Astrotomic\Tmdb\Models\TvGenre;
use Astrotomic\Tmdb\Models\WatchProvider;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
class TmdbServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->singleton(Tmdb::class);
}
public function boot(): void
{
Relation::morphMap(
collect([
Collection::class,
Credit::class,
Movie::class,
MovieGenre::class,
Person::class,
TvGenre::class,
WatchProvider::class,
])
->keyBy(
fn (string $model): string => Str::of($model)
->classBasename()
->singular()
->snake()
->prepend('tmdb.')
)
->all()
);
$this->publishes([
__DIR__.'/../database/migrations/' => database_path('migrations'),
], 'tmdb-migrations');
}
}