File size: 4,152 Bytes
52d9fb0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | <?php
namespace App\Providers;
use App\Models\User;
use App\Models\Order;
use App\Lib\Searchable;
use App\Models\Deposit;
use App\Models\Product;
use App\Models\Frontend;
use App\Constants\Status;
use App\Models\OrderItem;
use App\Models\Withdrawal;
use App\Models\SupportTicket;
use App\Models\AdminNotification;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Builder;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
Builder::mixin(new Searchable);
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
if (!cache()->get('SystemInstalled')) {
$envFilePath = base_path('.env');
if (!file_exists($envFilePath)) {
header('Location: install');
exit;
}
$envContents = file_get_contents($envFilePath);
if (empty($envContents)) {
header('Location: install');
exit;
} else {
cache()->put('SystemInstalled', true);
}
}
$activeTemplate = activeTemplate();
$viewShare['activeTemplate'] = $activeTemplate;
$viewShare['activeTemplateTrue'] = activeTemplate(true);
$viewShare['emptyMessage'] = 'Data not found';
view()->share($viewShare);
view()->composer('admin.partials.sidenav', function ($view) {
$view->with([
'bannedUsersCount' => User::banned()->count(),
'emailUnverifiedUsersCount' => User::emailUnverified()->count(),
'mobileUnverifiedUsersCount' => User::mobileUnverified()->count(),
'kycUnverifiedUsersCount' => User::kycUnverified()->count(),
'kycPendingUsersCount' => User::kycPending()->count(),
'pendingTicketCount' => SupportTicket::whereIN('status', [Status::TICKET_OPEN, Status::TICKET_REPLY])->count(),
'pendingDepositsCount' => Deposit::pending()->count(),
'pendingWithdrawCount' => Withdrawal::pending()->count(),
'pendingProductsCount' => Product::pending()->count(),
'paidOrdersCount' => Order::paid()->count(),
'refundedItemsCount' => OrderItem::refunded()->count(),
'updateAvailable' => version_compare(gs('available_version'),systemDetails()['version'],'>') ? 'v'.gs('available_version') : false,
]);
});
view()->composer('admin.partials.topnav', function ($view) {
$view->with([
'adminNotifications' => AdminNotification::where('is_read', Status::NO)->with('user')->orderBy('id', 'desc')->take(10)->get(),
'adminNotificationCount' => AdminNotification::where('is_read', Status::NO)->count(),
]);
});
view()->composer('reviewer.partials.sidenav', function ($view) {
$reviewer = auth('reviewer')->user();
$view->with([
'waitingProduct' => Product::whereIn('sub_category_id', @$reviewer->subcategories ?? [])->where(function ($q) {
$q->where('status', Status::PRODUCT_PENDING)->orWhere('product_updated', Status::PRODUCT_UPDATE_PENDING);
})->whereIn('assigned_to', [0, (@$reviewer->id ?? 0)])
->where('status', '!=', Status::PRODUCT_PERMANENT_DOWN)
->where('status', '!=', Status::PRODUCT_UPDATE_HARD_REJECT)
->where('status', '!=', Status::PRODUCT_HARD_REJECTED)
->count()
]);
});
view()->composer('partials.seo', function ($view) {
$seo = Frontend::where('data_keys', 'seo.data')->first();
$view->with([
'seo' => $seo ? $seo->data_values : $seo,
]);
});
if (gs('force_ssl')) {
\URL::forceScheme('https');
}
Paginator::useBootstrapFive();
}
}
|