72
app/Providers/AppServiceProvider.php
Executable file
72
app/Providers/AppServiceProvider.php
Executable file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Actions\AppValueLists;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Episode;
|
||||
use App\Models\NewsArticle;
|
||||
use App\Models\Person;
|
||||
use App\Models\Season;
|
||||
use App\Models\Title;
|
||||
use App\Services\Admin\GetAnalyticsHeaderData;
|
||||
use App\Services\AppBootstrapData;
|
||||
use App\Services\UrlGenerator;
|
||||
use Common\Admin\Analytics\Actions\GetAnalyticsHeaderDataAction;
|
||||
use Common\Core\Bootstrap\BootstrapData;
|
||||
use Common\Core\Contracts\AppUrlGenerator;
|
||||
use Common\Core\Values\ValueLists;
|
||||
use Common\Search\ImportRecordsIntoScout;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot(): void
|
||||
{
|
||||
$this->app->bind(BootstrapData::class, AppBootstrapData::class);
|
||||
|
||||
Relation::enforceMorphMap([
|
||||
Title::MODEL_TYPE => Title::class,
|
||||
'movie' => Title::class,
|
||||
'series' => Title::class,
|
||||
Season::MODEL_TYPE => Season::class,
|
||||
Episode::MODEL_TYPE => Episode::class,
|
||||
Person::MODEL_TYPE => Person::class,
|
||||
NewsArticle::MODEL_TYPE => NewsArticle::class,
|
||||
]);
|
||||
|
||||
Model::preventLazyLoading(!$this->app->isProduction());
|
||||
|
||||
// This will only work when loading from collection, because we need access to channel config
|
||||
Channel::resolveRelationUsing(
|
||||
'items',
|
||||
fn(Channel $channel) => $channel->morphedByMany(
|
||||
modelTypeToNamespace(
|
||||
$channel->config['contentModel'] ?? Title::class,
|
||||
),
|
||||
'channelable',
|
||||
),
|
||||
);
|
||||
|
||||
if (config('common.site.disable_scout_auto_sync')) {
|
||||
foreach (ImportRecordsIntoScout::getSearchableModels() as $model) {
|
||||
$model::disableSearchSyncing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function register(): void
|
||||
{
|
||||
// bind analytics
|
||||
$this->app->bind(
|
||||
GetAnalyticsHeaderDataAction::class,
|
||||
GetAnalyticsHeaderData::class,
|
||||
);
|
||||
|
||||
$this->app->bind(AppUrlGenerator::class, UrlGenerator::class);
|
||||
|
||||
$this->app->bind(ValueLists::class, AppValueLists::class);
|
||||
}
|
||||
}
|
||||
25
app/Providers/AuthServiceProvider.php
Executable file
25
app/Providers/AuthServiceProvider.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
}
|
||||
}
|
||||
21
app/Providers/BroadcastServiceProvider.php
Executable file
21
app/Providers/BroadcastServiceProvider.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes(['prefix' => 'secure', 'middleware' => 'web']);
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
38
app/Providers/EventServiceProvider.php
Executable file
38
app/Providers/EventServiceProvider.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Listeners\CreateWatchlist;
|
||||
use App\Listeners\DeleteUserChannels;
|
||||
use Common\Auth\Events\UserCreated;
|
||||
use Common\Auth\Events\UsersDeleted;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event listener mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
UserCreated::class => [
|
||||
CreateWatchlist::class,
|
||||
],
|
||||
UsersDeleted::class => [
|
||||
DeleteUserChannels::class
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
44
app/Providers/HorizonServiceProvider.php
Executable file
44
app/Providers/HorizonServiceProvider.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Horizon\HorizonApplicationServiceProvider;
|
||||
|
||||
class HorizonServiceProvider extends HorizonApplicationServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
// Horizon::routeSmsNotificationsTo('15556667777');
|
||||
// Horizon::routeMailNotificationsTo('example@example.com');
|
||||
// Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');
|
||||
|
||||
// Horizon::night();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Horizon gate.
|
||||
*
|
||||
* This gate determines who can access Horizon in non-local environments.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function gate()
|
||||
{
|
||||
Gate::define('viewHorizon', function (User $user) {
|
||||
if (config('common.site.demo')) {
|
||||
return $user->email === 'Ic0OdCIodqz8q1r@demo.com';
|
||||
} else {
|
||||
return $user->hasPermission('admin');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
85
app/Providers/RouteServiceProvider.php
Executable file
85
app/Providers/RouteServiceProvider.php
Executable file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use Auth;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'App\Http\Controllers';
|
||||
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Route::bind('user', function ($value) {
|
||||
$id = $value === 'me' ? Auth::id() : (int) $value;
|
||||
return User::findOrFail($id);
|
||||
});
|
||||
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user