mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-12 20:20:41 -05:00
- Updated the SptVersion and ModVersion dependancies to resolve *all* compatible versions and introduced new relationships to pull just the latest compatible version. Had to rewrite a *bunch*, but it should be much more capable now. It can be expensive to resolve these properties when iterated over, so *make sure they're eager loaded using the `with` method when you're building the queries*. - Updated the mod listing Livewire component to save the filter options within the PHP session instead of in browser local storage. *Much* cleaner. - Removed caching from homepage queries to see how they preform on production. Will add back later. - Updated ModVersion factory to create SptVersions if there are none specified. - Probably lots of other changes too... I need to make smaller commits. :(
62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Mod;
|
|
use App\Models\ModDependency;
|
|
use App\Models\ModVersion;
|
|
use App\Models\SptVersion;
|
|
use App\Models\User;
|
|
use App\Observers\ModDependencyObserver;
|
|
use App\Observers\ModObserver;
|
|
use App\Observers\ModVersionObserver;
|
|
use App\Observers\SptVersionObserver;
|
|
use App\Services\LatestSptVersionService;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Number;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
$this->app->singleton(LatestSptVersionService::class, function ($app) {
|
|
return new LatestSptVersionService;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
// Allow mass assignment for all models. Be careful!
|
|
Model::unguard();
|
|
|
|
// Register observers.
|
|
Mod::observe(ModObserver::class);
|
|
ModVersion::observe(ModVersionObserver::class);
|
|
ModDependency::observe(ModDependencyObserver::class);
|
|
SptVersion::observe(SptVersionObserver::class);
|
|
|
|
// This gate determines who can access the Pulse dashboard.
|
|
Gate::define('viewPulse', function (User $user) {
|
|
return $user->isAdmin();
|
|
});
|
|
|
|
// Register a number macro to format download numbers.
|
|
Number::macro('downloads', function (int|float $number) {
|
|
return Number::forHumans(
|
|
$number,
|
|
$number > 1000000 ? 2 : ($number > 1000 ? 1 : 0),
|
|
maxPrecision: null,
|
|
abbreviate: true
|
|
);
|
|
});
|
|
}
|
|
}
|