state cart null
This commit is contained in:
parent
156978e669
commit
9a23e75f5b
|
|
@ -79,4 +79,18 @@ class CartController extends Controller
|
||||||
|
|
||||||
return redirect()->route('cart.index');
|
return redirect()->route('cart.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clear(MemberCartRepository $repository)
|
||||||
|
{
|
||||||
|
$repository->clearAll();
|
||||||
|
|
||||||
|
if (request()->expectsJson()) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Cart cleared successfully'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('cart.index');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,14 @@ class MemberCartRepository
|
||||||
->sum('qty');
|
->sum('qty');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function clearAll($locationId = null)
|
||||||
|
{
|
||||||
|
$location = $locationId ?? session('location_id', 22);
|
||||||
|
return Cart::where('user_id', auth()->user()->id)
|
||||||
|
->where('location_id', $location)
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getList($request)
|
public function getList($request)
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -258,15 +258,16 @@
|
||||||
style="--cz-badge-padding-y: .25em; --cz-badge-padding-x: .42em">{{ auth()->check() ? \App\Repositories\Member\Cart\MemberCartRepository::getCount() : 0 }}</span>
|
style="--cz-badge-padding-y: .25em; --cz-badge-padding-x: .42em">{{ auth()->check() ? \App\Repositories\Member\Cart\MemberCartRepository::getCount() : 0 }}</span>
|
||||||
<i class="ci-shopping-bag animate-target me-1"></i>
|
<i class="ci-shopping-bag animate-target me-1"></i>
|
||||||
</button> --}}
|
</button> --}}
|
||||||
<a type="button"
|
<a type="button" href="{{ route('cart.index') }}"
|
||||||
href="{{ route('cart.index') }}"
|
|
||||||
class="btn btn-icon btn-lg fs-xl btn-outline-secondary position-relative border-0 rounded-circle animate-scale"
|
class="btn btn-icon btn-lg fs-xl btn-outline-secondary position-relative border-0 rounded-circle animate-scale"
|
||||||
aria-label="Shopping cart">
|
aria-label="Shopping cart">
|
||||||
<span
|
@if (auth()->check() && \App\Repositories\Member\Cart\MemberCartRepository::getCount() > 0)
|
||||||
class="position-absolute top-0 start-100 badge fs-xs text-bg-primary rounded-pill mt-1 ms-n4 z-2 cart-count"
|
<span
|
||||||
style="--cz-badge-padding-y: .25em; --cz-badge-padding-x: .42em">{{ auth()->check() ? \App\Repositories\Member\Cart\MemberCartRepository::getCount() : 0 }}</span>
|
class="position-absolute top-0 start-100 badge fs-xs text-bg-primary rounded-pill mt-1 ms-n4 z-2 cart-count"
|
||||||
|
style="--cz-badge-padding-y: .25em; --cz-badge-padding-x: .42em">{{ auth()->check() ? \App\Repositories\Member\Cart\MemberCartRepository::getCount() : 0 }}</span>
|
||||||
|
@endif
|
||||||
<i class="ci-shopping-bag animate-target me-1"></i>
|
<i class="ci-shopping-bag animate-target me-1"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ Route::middleware(['auth'])->prefix('/cart')->group(function () {
|
||||||
Route::get('/', [CartController::class, 'index'])->name('cart.index');
|
Route::get('/', [CartController::class, 'index'])->name('cart.index');
|
||||||
Route::post('/', [CartController::class, 'add'])->name('cart.add');
|
Route::post('/', [CartController::class, 'add'])->name('cart.add');
|
||||||
Route::put('/{id}', [CartController::class, 'update'])->name('cart.update');
|
Route::put('/{id}', [CartController::class, 'update'])->name('cart.update');
|
||||||
|
Route::delete('/clear', [CartController::class, 'clear'])->name('cart.clear');
|
||||||
Route::delete('/{id}', [CartController::class, 'delete'])->name('cart.delete');
|
Route::delete('/{id}', [CartController::class, 'delete'])->name('cart.delete');
|
||||||
Route::get('/count', [CartController::class, 'count'])->name('cart.count');
|
Route::get('/count', [CartController::class, 'count'])->name('cart.count');
|
||||||
});
|
});
|
||||||
Loading…
Reference in New Issue