@php use App\Models\SellerStore; use App\Models\Store; use Illuminate\Support\Facades\Auth; use App\Services\StoreService; use App\Services\TranslationService; use App\Services\MediaService; $language_code = app(TranslationService::class)->getLanguageCode(); $user = Auth::user(); $isPublicDisk = $user->disk == 'public' ? 1 : 0; $seller_detail = fetchDetails(SellerStore::class, ['user_id' => $user->id, 'status' => 1], 'store_id'); $store_ids = []; foreach ($seller_detail as $row) { $store_ids[] = $row->store_id; } $store_details = Store::whereIn('id', $store_ids)->where('status', 1)->get(); if (session('store_id') !== null && in_array(session('store_id'), $store_ids)) { // Use the existing session store ID if it's valid $store_id = session('store_id'); } else { // Use the first store in the list as default $store_id = $store_details->isEmpty() ? 0 : $store_details[0]->id; // Set session data for the default store if ($store_id !== 0) { session(['store_id' => $store_id]); session(['store_name' => $store_details[0]->name]); session(['store_image' => $store_details[0]->image]); } else { // Handle the case where no valid store is found // You might want to set default values or handle this situation differently } } $user_image = $isPublicDisk ? (!empty($user->image) && file_exists(public_path(config('constants.SELLER_IMG_PATH') . $user->image)) ? app(MediaService::class)->getMediaImageUrl($user->image, 'SELLER_IMG_PATH') : app(MediaService::class)->getImageUrl('no-user-img.jpeg', '', '', 'image', 'NO_USER_IMAGE')) : $user->image; // Retrieve session data for store name and image $store_name = session('store_name', ''); $store_image = session('store_image', ''); // If store_image is set, generate the asset URL if (!empty($store_image)) { $store_image = asset(config('constants.STORE_IMG_PATH') . $store_image); } use App\Models\Language; $languages = Language::all(); @endphp @php $store_id = app(StoreService::class)->getStoreId(); $store_details = fetchDetails( Store::class, ['id' => $store_id], ['primary_color', 'secondary_color', 'hover_color', 'active_color'], ); $primary_colour = isset($store_details[0]->primary_color) && !empty($store_details[0]->primary_color) ? $store_details[0]->primary_color : '#B52046'; $secondary_color = isset($store_details[0]->secondary_color) && !empty($store_details[0]->secondary_color) ? $store_details[0]->secondary_color : '#201A1A'; $hover_color = isset($store_details[0]->hover_color) && !empty($store_details[0]->hover_color) ? $store_details[0]->hover_color : '#911A38'; $active_color = isset($store_details[0]->active_color) && !empty($store_details[0]->active_color) ? $store_details[0]->active_color : '#6D132A'; $background_opacity_color = $primary_colour . '10'; @endphp