Audit items #15, #16, #20, #22. #15 — AuthController::me and UserResource form/table now read tier via PlanFeatures::for($user)->tier() instead of Plan::resolveForUser($user) ->name. Tiers.md: PlanFeatures is the single entitlement gate. #16 — Moved SQLite GREATEST/LEAST PHP-backed function registration from AppServiceProvider::boot to tests/TestCase::setUp. Production app boot no longer checks the DB driver name. #20 — FetchOilPrices: added Log::warning on EIA fallback and Log::error on both-providers-failed so primary-source reliability can be trended beyond the cron output buffer. #22 — FuelPriceService::flattenEnabledFlags is now an instance method, matching the rest of the class. No external callers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
73 lines
2.0 KiB
PHP
73 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Listeners\HandleStripeWebhook;
|
|
use App\Models\Subscription;
|
|
use App\Services\ApiLogger;
|
|
use App\Services\LlmPrediction\AnthropicPredictionProvider;
|
|
use App\Services\LlmPrediction\GeminiPredictionProvider;
|
|
use App\Services\LlmPrediction\OilPredictionProvider;
|
|
use App\Services\LlmPrediction\OpenAiPredictionProvider;
|
|
use Carbon\CarbonImmutable;
|
|
use Illuminate\Support\Facades\Date;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Illuminate\Validation\Rules\Password;
|
|
use Laravel\Cashier\Cashier;
|
|
use Laravel\Cashier\Events\WebhookReceived;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
$this->app->bind(OilPredictionProvider::class, function ($app) {
|
|
$logger = $app->make(ApiLogger::class);
|
|
|
|
return match (config('services.llm.provider')) {
|
|
'openai' => new OpenAiPredictionProvider($logger),
|
|
'gemini' => new GeminiPredictionProvider($logger),
|
|
default => new AnthropicPredictionProvider($logger),
|
|
};
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
$this->configureDefaults();
|
|
|
|
Cashier::useSubscriptionModel(Subscription::class);
|
|
|
|
Event::listen(WebhookReceived::class, HandleStripeWebhook::class);
|
|
}
|
|
|
|
/**
|
|
* Configure default behaviors for production-ready applications.
|
|
*/
|
|
protected function configureDefaults(): void
|
|
{
|
|
Date::use(CarbonImmutable::class);
|
|
|
|
DB::prohibitDestructiveCommands(
|
|
app()->isProduction(),
|
|
);
|
|
|
|
Password::defaults(fn (): ?Password => app()->isProduction()
|
|
? Password::min(12)
|
|
->mixedCase()
|
|
->letters()
|
|
->numbers()
|
|
->symbols()
|
|
->uncompromised()
|
|
: null,
|
|
);
|
|
}
|
|
}
|