2026-07-03 13:46:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
|
|
|
|
use App\Models\Customer;
|
|
|
|
|
use App\Models\Staff;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
|
|
|
|
use Illuminate\Support\Facades\URL;
|
2026-08-29 00:17:34 +03:00
|
|
|
use Illuminate\Support\Facades\View;
|
2026-07-03 13:46:54 +00:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2026-08-29 00:17:34 +03:00
|
|
|
use Illuminate\View\View as ViewInstance;
|
2026-07-03 13:46:54 +00:00
|
|
|
use Lunar\Facades\ModelManifest;
|
|
|
|
|
use Lunar\Facades\Telemetry;
|
2026-08-29 00:17:34 +03:00
|
|
|
use Modules\Core\Catalog\DTOs\CollectionFilters;
|
|
|
|
|
use Modules\Core\Catalog\Enums\CollectionSort;
|
|
|
|
|
use Modules\Core\Catalog\Services\CollectionService;
|
2026-07-03 13:46:54 +00:00
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
2026-09-24 17:27:58 +03:00
|
|
|
public function register(): void
|
|
|
|
|
{
|
|
|
|
|
// One instance per request: it caches the guest cookie's ids, so a
|
|
|
|
|
// toggle and a later has() in the same request agree.
|
|
|
|
|
$this->app->scoped(\App\Services\Wishlist::class);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-03 13:46:54 +00:00
|
|
|
public function boot(): void
|
|
|
|
|
{
|
|
|
|
|
Telemetry::optOut();
|
|
|
|
|
|
2026-08-29 00:17:34 +03:00
|
|
|
// header.blade.php's category dropdown — root collections only, resolved
|
|
|
|
|
// per-request so the composer runs after `locale` middleware has already
|
|
|
|
|
// set App::getLocale(), which CollectionService's name resolution depends on.
|
|
|
|
|
View::composer('components.header', function (ViewInstance $view) {
|
|
|
|
|
$view->with('categories', app(CollectionService::class)->list(
|
|
|
|
|
filters: new CollectionFilters(rootOnly: true),
|
|
|
|
|
perPage: 100,
|
|
|
|
|
sort: CollectionSort::Position,
|
|
|
|
|
)->items());
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-03 13:46:54 +00:00
|
|
|
if ($this->app->environment('production')) {
|
|
|
|
|
URL::forceScheme('https');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->app->booted(function () {
|
|
|
|
|
ModelManifest::replace(
|
|
|
|
|
\Lunar\Models\Contracts\Customer::class,
|
|
|
|
|
Customer::class,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->app['config']->set(
|
|
|
|
|
'auth.providers.staff.model',
|
|
|
|
|
Staff::class,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Relation::morphMap([
|
|
|
|
|
'staff' => \Lunar\Admin\Models\Staff::class,
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|