Compare commits

..

2 Commits

Author SHA1 Message Date
bayu 2ab0549f02 add new arrivals 2025-12-31 13:14:30 +07:00
bayu a3675b87c9 location & language 2025-12-31 11:04:13 +07:00
19 changed files with 408 additions and 191 deletions

View File

@ -0,0 +1,25 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
class LocationController extends Controller
{
/**
* Handle location selection request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function select(Request $request): JsonResponse
{
$locationId = $request->input('location_id');
// Store location ID in session
session(['location_id' => $locationId]);
return response()->json(['success' => true]);
}
}

View File

@ -238,26 +238,31 @@ class Items extends Model
});
return $this->hasOne(Discount::class,DB::raw("item_reference.item_id"))
->leftJoin("discount_items","discounts.id","=","discount_id")
->leftJoin("item_reference","item_reference.id","=","item_reference_id")
->where("discounts.type","price")
->orderBy("discounts.created_at","desc")
return $this->hasOne(Discount::class, 'id', 'item_reference_id')
->leftJoin('discount_items', 'discount_items.discount_id', '=', 'discounts.id')
->where('discounts.type', 'price')
->where(function ($query) {
$query->whereNull("valid_at")
->orWhereDate("valid_at", "<=", Carbon::now());
$query->where('valid_at', '<=', now())
->orWhereNull('valid_at');
})
->where(function ($query) {
$query->whereNull("expired_at")
->orWhereDate("expired_at", ">=", Carbon::now());
$query->where('expired_at', '>', now())
->orWhereNull('expired_at');
})
->where(function ($query) use ($location_id, $is_consignment) {
if (!$is_consignment)
$query->whereNull("discounts.location_id");
if ($location_id)
$query->orWhere("discounts.location_id", $location_id);
if (!$is_consignment) {
$query->whereNull('discounts.location_id');
}
if ($location_id) {
$query->orWhere('discounts.location_id', $location_id);
}
})
->select("item_id","price");
->orderByDesc('discounts.created_at')
->select([
'discount_items.item_reference_id',
'discount_items.price',
]);
}
public function stock()

View File

@ -0,0 +1,28 @@
<?php
namespace App\View\Components\Home;
use App\Repositories\Catalog\ProductRepository;
use Illuminate\View\Component;
use Illuminate\View\View;
class NewArrivals extends Component
{
public $products;
public function __construct(ProductRepository $productRepository)
{
$params = [
'sort' => 'new',
];
$this->products = $productRepository->getList($params);
}
/**
* Get the view/contents that represent the component.
*/
public function render(): View
{
return view('components.home.new-arrivals');
}
}

View File

@ -5,7 +5,7 @@ namespace App\View\Components;
use Illuminate\View\Component;
use Illuminate\View\View;
class CountrySelector extends Component
class LanguageSelector extends Component
{
/**
* Create a new component instance.
@ -20,6 +20,6 @@ class CountrySelector extends Component
*/
public function render(): View
{
return view('components.country-selector');
return view('components.language-selector');
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
use Illuminate\View\View;
class LanguageSelectorSidebar extends Component
{
/**
* Create a new component instance.
*/
public function __construct()
{
//
}
/**
* Get the view/contents that represent the component.
*/
public function render(): View
{
return view('components.language-selector-sidebar');
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace App\View\Components;
use App\Models\Location;
use Illuminate\View\Component;
use Illuminate\View\View;
class LocationSelector extends Component
{
public Location $selected;
public $locations;
/**
* Create a new component instance.
*/
public function __construct()
{
// Get location ID from session, default to 22 if not set
$locationId = session('location_id', 22);
$this->selected = Location::where('id', $locationId)->first();
$this->locations = Location::whereNotNull('display_name')
->whereNot('display_name', '=', '')
->orderBy('display_name')
->get();
}
/**
* Get the view/contents that represent the component.
*/
public function render(): View
{
return view('components.location-selector');
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace App\View\Components;
use App\Models\Location;
use Illuminate\View\Component;
use Illuminate\View\View;
class LocationSelectorSidebar extends Component
{
public Location $selected;
public $locations;
/**
* Create a new component instance.
*/
public function __construct()
{
// Get location ID from session, default to 22 if not set
$locationId = session('location_id', 22);
$this->selected = Location::where('id', $locationId)->first();
$this->locations = Location::whereNotNull('display_name')
->whereNot('display_name', '=', '')
->orderBy('display_name')
->get();
}
/**
* Get the view/contents that represent the component.
*/
public function render(): View
{
return view('components.location-selector-sidebar');
}
}

BIN
public/logo/icon.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
public/logo/logo-app.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

View File

@ -0,0 +1,97 @@
<!-- Special collection carousel -->
<section class="container pb-5 mb-2 mb-sm-3 mb-lg-4 mb-xl-5">
<div class="d-md-none text-center pb-3 mb-3">
<p class="mb-2">New arrivals</p>
<h2 class="mb-0">Meet the {{ config('app.name') }} collection</h2>
</div>
<div class="row align-items-center pb-xxl-3">
<!-- Preview images (controlled slider) -->
<div class="col-md-7 order-md-2 mb-4 mb-md-0">
<div class="swiper user-select-none" id="previewImages"
data-swiper='{
"allowTouchMove": false,
"loop": true,
"effect": "fade",
"fadeEffect": {
"crossFade": true
}
}'>
<div class="swiper-wrapper">
@foreach ($products as $key => $product)
<div class="swiper-slide">
<div class="ratio" style="--cz-aspect-ratio: calc(720 / 746 * 100%)">
<img src="{{ $product->image_url }}" class="rounded-5" alt="Image">
</div>
</div>
@endforeach
</div>
</div>
</div>
<!-- Products master slider -->
<div class="col-md-5 order-md-1 text-center">
<div class="d-none d-md-block pb-3 mb-2 mb-lg-3 mx-auto" style="max-width: 306px">
<p class="mb-2">New arrivals</p>
<h2 class="mb-0">Meet the Cartzilla collection</h2>
</div>
<div class="d-flex align-items-center justify-content-center">
<!-- Prev button -->
<button type="button"
class="btn btn-icon btn-outline-secondary animate-slide-start rounded-circle mt-n5"
id="collectionPrev" aria-label="Prev">
<i class="ci-chevron-left fs-lg animate-target"></i>
</button>
<!-- Slider -->
<div class="swiper mx-3 mx-lg-4"
data-swiper='{
"spaceBetween": 24,
"loop": true,
"speed": 400,
"controlSlider": "#previewImages",
"navigation": {
"prevEl": "#collectionPrev",
"nextEl": "#collectionNext"
}
}'
style="max-width: 306px">
<div class="swiper-wrapper">
@foreach ($products as $key => $product)
<div class="swiper-slide">
<div class="animate-underline hover-effect-opacity">
<a class="d-flex bg-body-tertiary rounded p-3 mb-3"
href="{{ route('second', ['shop', 'product-fashion']) }}">
<div class="ratio" style="--cz-aspect-ratio: calc(308 / 274 * 100%)">
<img src="{{ $product->image_url }}" loading="lazy" class="w-100 h-100 object-cover">
</div>
</a>
<div class="nav justify-content-center mb-2">
<a class="nav-link animate-target min-w-0 text-dark-emphasis p-0"
href="{{ route('second', ['shop', 'product-fashion']) }}">
<span class="text-truncate">{{ $product->name }}</span>
</a>
</div>
<div class="h6 mb-0">{{ number_format($product->price, 0, ',', '.') }}</div>
</div>
</div>
@endforeach
</div>
</div>
<!-- Next button -->
<button type="button"
class="btn btn-icon btn-outline-secondary animate-slide-end rounded-circle mt-n5"
id="collectionNext" aria-label="Next">
<i class="ci-chevron-right fs-lg animate-target"></i>
</button>
</div>
</div>
</div>
</section>

View File

@ -0,0 +1,22 @@
<!-- Language selector for sidebar/offcanvas -->
<div class="dropdown nav">
<a class="nav-link dropdown-toggle py-1 px-0" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-label="{{ __('messages.Country select') }}: USA">
<div class="ratio ratio-1x1" style="width: 20px">
<img src="/img/flags/en-us.png" alt="USA">
</div>
</a>
<ul class="dropdown-menu fs-sm" style="--cz-dropdown-spacer: .5rem">
<li>
<a class="dropdown-item" href="#!">
<img src="/img/flags/en-us.png" class="flex-shrink-0 me-2" width="20" alt="United States">
{{ __('languages.en') }}
</a>
</li>
<li>
<a class="dropdown-item" href="#!">
<img src="/img/flags/id.png" class="flex-shrink-0 me-2" width="20" alt="Indonesia">
{{ __('languages.id') }}
</a>
</li>
</ul>
</div>

View File

@ -0,0 +1,44 @@
<!-- Location selector for sidebar -->
<div class="dropdown nav">
<a class="nav-link animate-underline dropdown-toggle fw-normal py-1 px-0" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="animate-target location-name-sidebar">{{ $selected->display_name ?? '-'}}</span>
</a>
<ul class="dropdown-menu fs-sm" style="--cz-dropdown-spacer: .5rem">
@foreach ($locations as $loc)
<li>
<a class="dropdown-item" href="#"
onclick="selectLocationSidebar({{ $loc->id }}, '{{ $loc->display_name }}')">
{{ $loc->display_name }}
</a>
</li>
@endforeach
</ul>
</div>
<script>
function selectLocationSidebar(locationId, locationName) {
// Store location in session via AJAX
fetch('/location/select', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify({
location_id: locationId
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Update the displayed location
document.querySelector('.location-name-sidebar').textContent = locationName;
// Reload page to reflect changes
window.location.reload();
}
})
.catch(error => console.error('Error selecting location:', error));
}
</script>

View File

@ -0,0 +1,44 @@
<!-- City selector visible on screens > 768px wide (md breakpoint) -->
<div class="dropdown d-none d-md-block nav">
<a class="nav-link animate-underline dropdown-toggle fw-normal py-1 px-0" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="animate-target location-name">{{ $selected->display_name ?? '-'}}</span>
</a>
<ul class="dropdown-menu fs-sm" style="--cz-dropdown-spacer: .5rem">
@foreach ($locations as $loc)
<li>
<a class="dropdown-item" href="#"
onclick="selectLocation({{ $loc->id }}, '{{ $loc->display_name }}')">
{{ $loc->display_name }}
</a>
</li>
@endforeach
</ul>
</div>
<script>
function selectLocation(locationId, locationName) {
// Store location in session via AJAX
fetch('/location/select', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify({
location_id: locationId
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Update the displayed location
document.querySelector('.location-name').textContent = locationName;
// Reload page to reflect changes
window.location.reload();
}
})
.catch(error => console.error('Error selecting location:', error));
}
</script>

View File

@ -1,4 +1,4 @@
@extends('layouts.landing', ['title' => 'Fashion Store v.1'])
@extends('layouts.landing', ['title' => 'AsiaGolf Store'])
@section('content')
<div class="offcanvas offcanvas-end pb-sm-2 px-sm-2" id="shoppingCart" tabindex="-1" aria-labelledby="shoppingCartLabel"
@ -199,24 +199,18 @@
</button>
<!-- Country selector visible on screens > 768px wide (md breakpoint) -->
<x-country-selector />
<x-language-selector />
<!-- City slect visible on screens > 768px wide (md breakpoint) -->
<div class="dropdown d-none d-md-block nav">
<a class="nav-link animate-underline dropdown-toggle fw-normal py-1 px-0" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="animate-target">Washington</span>
</a>
<ul class="dropdown-menu fs-sm" style="--cz-dropdown-spacer: .5rem">
<li><a class="dropdown-item" href="#!">Chicago</a></li>
<li><a class="dropdown-item" href="#!">Los Angeles</a></li>
<li><a class="dropdown-item" href="#!">New York</a></li>
<li><a class="dropdown-item" href="#!">Philadelphia</a></li>
</ul>
</div>
<!-- LOcation selector visible on screens > 768px wide (md breakpoint) -->
<x-location-selector />
</div>
<!-- Navbar brand (Logo) -->
<a class="navbar-brand fs-2 py-0 m-0 me-auto me-sm-n5" href="/">Cartzilla</a>
<a class="navbar-brand fs-2 py-0 m-0 me-auto me-sm-n5" href="/">
<img src="{{ asset('logo/logo-colored.png') }}" class="d-none d-lg-block" style="height:32px;"/>
<img src="{{ asset('logo/logo-app.png') }}" class="d-lg-none" style="height:42px;"/>
</a>
<!-- Button group -->
<div class="d-flex align-items-center">
@ -297,52 +291,10 @@
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<!-- Country and City slects visible on screens < 768px wide (md breakpoint) -->
<!-- Country and City selects visible on screens < 768px wide (md breakpoint) -->
<div class="offcanvas-header gap-3 d-md-none pt-0 pb-3">
<div class="dropdown nav">
<a class="nav-link dropdown-toggle py-1 px-0" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-label="Country select: USA">
<div class="ratio ratio-1x1" style="width: 20px">
<img src="/img/flags/en-us.png" alt="USA">
</div>
</a>
<ul class="dropdown-menu fs-sm" style="--cz-dropdown-spacer: .5rem">
<li>
<a class="dropdown-item" href="#!">
<img src="/img/flags/en-uk.png" class="flex-shrink-0 me-2" width="20" alt="United Kingdom">
United Kingdom
</a>
</li>
<li>
<a class="dropdown-item" href="#!">
<img src="/img/flags/fr.png" class="flex-shrink-0 me-2" width="20" alt="France">
France
</a>
</li>
<li>
<a class="dropdown-item" href="#!">
<img src="/img/flags/de.png" class="flex-shrink-0 me-2" width="20" alt="Deutschland">
Deutschland
</a>
</li>
<li>
<a class="dropdown-item" href="#!">
<img src="/img/flags/it.png" class="flex-shrink-0 me-2" width="20" alt="Italia">
Italia
</a>
</li>
</ul>
</div>
<div class="dropdown nav">
<a class="nav-link animate-underline dropdown-toggle fw-normal py-1 px-0" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="animate-target">Washington</span>
</a>
<ul class="dropdown-menu fs-sm" style="--cz-dropdown-spacer: .5rem">
<li><a class="dropdown-item" href="#!">Chicago</a></li>
<li><a class="dropdown-item" href="#!">Los Angeles</a></li>
<li><a class="dropdown-item" href="#!">New York</a></li>
<li><a class="dropdown-item" href="#!">Philadelphia</a></li>
</ul>
</div>
<x-language-selector-sidebar />
<x-location-selector-sidebar />
</div>
<div class="offcanvas-body pt-1 pb-3 py-lg-0">
<div class="container pb-lg-2 px-0 px-lg-3">
@ -1316,119 +1268,7 @@
<x-home.product-highlight />
<!-- Special collection carousel -->
<section class="container pb-5 mb-2 mb-sm-3 mb-lg-4 mb-xl-5">
<div class="d-md-none text-center pb-3 mb-3">
<p class="mb-2">New arrivals</p>
<h2 class="mb-0">Meet the Cartzilla collection</h2>
</div>
<div class="row align-items-center pb-xxl-3">
<!-- Preview images (controlled slider) -->
<div class="col-md-7 order-md-2 mb-4 mb-md-0">
<div class="swiper user-select-none" id="previewImages"
data-swiper='{
"allowTouchMove": false,
"loop": true,
"effect": "fade",
"fadeEffect": {
"crossFade": true
}
}'>
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="ratio" style="--cz-aspect-ratio: calc(720 / 746 * 100%)">
<img src="/img/home/fashion/v1/collection/01.jpg" class="rounded-5" alt="Image">
</div>
</div>
<div class="swiper-slide">
<div class="ratio" style="--cz-aspect-ratio: calc(720 / 746 * 100%)">
<img src="/img/home/fashion/v1/collection/02.jpg" class="rounded-5" alt="Image">
</div>
</div>
</div>
</div>
</div>
<!-- Products master slider -->
<div class="col-md-5 order-md-1 text-center">
<div class="d-none d-md-block pb-3 mb-2 mb-lg-3 mx-auto" style="max-width: 306px">
<p class="mb-2">New arrivals</p>
<h2 class="mb-0">Meet the Cartzilla collection</h2>
</div>
<div class="d-flex align-items-center justify-content-center">
<!-- Prev button -->
<button type="button"
class="btn btn-icon btn-outline-secondary animate-slide-start rounded-circle mt-n5"
id="collectionPrev" aria-label="Prev">
<i class="ci-chevron-left fs-lg animate-target"></i>
</button>
<!-- Slider -->
<div class="swiper mx-3 mx-lg-4"
data-swiper='{
"spaceBetween": 24,
"loop": true,
"speed": 400,
"controlSlider": "#previewImages",
"navigation": {
"prevEl": "#collectionPrev",
"nextEl": "#collectionNext"
}
}'
style="max-width: 306px">
<div class="swiper-wrapper">
<!-- Item -->
<div class="swiper-slide">
<div class="animate-underline hover-effect-opacity">
<a class="d-flex bg-body-tertiary rounded p-3 mb-3"
href="{{ route('second', ['shop', 'product-fashion']) }}">
<div class="ratio" style="--cz-aspect-ratio: calc(308 / 274 * 100%)">
<img src="/img/shop/fashion/03.png" alt="Image">
</div>
</a>
<div class="nav justify-content-center mb-2">
<a class="nav-link animate-target min-w-0 text-dark-emphasis p-0"
href="{{ route('second', ['shop', 'product-fashion']) }}">
<span class="text-truncate">Sneakers with a massive sole</span>
</a>
</div>
<div class="h6 mb-0">$86.50</div>
</div>
</div>
<!-- Item -->
<div class="swiper-slide">
<div class="animate-underline hover-effect-opacity">
<a class="d-flex bg-body-tertiary rounded p-3 mb-3"
href="{{ route('second', ['shop', 'product-fashion']) }}">
<div class="ratio" style="--cz-aspect-ratio: calc(308 / 274 * 100%)">
<img src="/img/shop/fashion/12.png" alt="Image">
</div>
</a>
<div class="nav justify-content-center mb-2">
<a class="nav-link animate-target min-w-0 text-dark-emphasis p-0"
href="{{ route('second', ['shop', 'product-fashion']) }}">
<span class="text-truncate">Single breasted oversized blazer</span>
</a>
</div>
<div class="h6 mb-0">$113.99</div>
</div>
</div>
</div>
</div>
<!-- Next button -->
<button type="button"
class="btn btn-icon btn-outline-secondary animate-slide-end rounded-circle mt-n5"
id="collectionNext" aria-label="Next">
<i class="ci-chevron-right fs-lg animate-target"></i>
</button>
</div>
</div>
</div>
</section>
<x-home.new-arrivals />
<!-- Brands -->

View File

@ -1,10 +1,13 @@
<meta charset="utf-8">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<!-- Viewport -->
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover">
<!-- SEO Meta Tags -->
<title>Cartzilla | {{ $title }}</title>
<title>{{ config('app.name') }} | {{ $title }}</title>
<meta name="description" content="Cartzilla - Multipurpose Bootstrap E-Commerce HTML Template">
<meta name="keywords"
content="online shop, e-commerce, online store, market, multipurpose, product landing, cart, checkout, ui kit, light and dark mode, bootstrap, html5, css3, javascript, gallery, slider, mobile, pwa">

View File

@ -3,6 +3,7 @@
use App\Http\Controllers\HomeController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\RoutingController;
use App\Http\Controllers\LocationController;
Route::group(['prefix' => '/dummy'], function () {
Route::get('', [RoutingController::class, 'index'])->name('root');
@ -12,4 +13,7 @@ Route::group(['prefix' => '/dummy'], function () {
});
// Location selection route
Route::post('/location/select', [LocationController::class, 'select'])->name('location.select');
Route::get('/', [HomeController::class, 'index'])->name('home');