Consolidate prediction functionality by merging /api/prediction endpoint into /api/stations response. Move prediction logic from PredictionController into StationController, returning prediction data alongside station results. Replace usePrediction composable with unified useStations that returns {stations, meta, prediction}. Remove PredictionRequest, related tests, and unused Vue components (FuelFinderTest, MapTest, RecommendationTest, StationListTest). Add PredictionFull component and UpsellBanner. Extend NationalFuelPredictionService to include weekly_summary (7-day series, yesterday/today averages, cheapest/priciest days) and oil signal from price_predictions table. Update Home.vue to consume prediction from stations response. Add Plan::resolveCadenceForUser helper and configure Cashier to use custom Subscription model.
80 lines
2.4 KiB
PHP
80 lines
2.4 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(),
|
|
);
|
|
|
|
// SQLite lacks GREATEST/LEAST scalar functions — register them for tests.
|
|
if (DB::connection()->getDriverName() === 'sqlite') {
|
|
$pdo = DB::connection()->getPdo();
|
|
$pdo->sqliteCreateFunction('GREATEST', fn (...$args) => max($args), -1);
|
|
$pdo->sqliteCreateFunction('LEAST', fn (...$args) => min($args), -1);
|
|
}
|
|
|
|
Password::defaults(fn (): ?Password => app()->isProduction()
|
|
? Password::min(12)
|
|
->mixedCase()
|
|
->letters()
|
|
->numbers()
|
|
->symbols()
|
|
->uncompromised()
|
|
: null,
|
|
);
|
|
}
|
|
}
|