customer section

This commit is contained in:
Abhishek Mali
2025-11-18 10:01:59 +05:30
parent df89031d36
commit 63daef6a92
10 changed files with 664 additions and 12 deletions

View File

@@ -1,12 +1,176 @@
@extends('admin.layouts.app')
@section('page-title', 'Dashboard')
@section('page-title', 'Customers')
@section('content')
<style>
.btn.active {
opacity: 1 !important;
border-width: 2px;
}
.btn {
opacity: 0.85;
}
.bg-purple {
background: #7c3aed !important;
color: white !important;
}
</style>
<div class="card shadow-sm">
<div class="card-body">
<h4>Welcome to the Admin customer page</h4>
<p>Here you can manage all system modules.</p>
</div>
<div class="card-body">
<h4 class="mb-3">Customer List</h4>
{{-- SEARCH + STATUS FILTER ROW --}}
<div class="d-flex justify-content-between align-items-center mb-3">
{{-- SEARCH BAR --}}
<form method="GET" action="{{ route('admin.customers.index') }}" class="d-flex" style="gap:10px;">
<input type="text"
name="search"
value="{{ $search ?? '' }}"
class="form-control"
placeholder="Search customer name, email, mobile, customer ID...">
{{-- Preserve status on search --}}
@if(!empty($status))
<input type="hidden" name="status" value="{{ $status }}">
@endif
<button class="btn btn-primary">
<i class="bi bi-search"></i>
</button>
</form>
{{-- STATUS FILTER --}}
<div>
<a href="{{ route('admin.customers.index', ['status'=>'active', 'search'=>$search ?? '']) }}"
class="btn btn-success {{ ($status ?? '') == 'active' ? 'active' : '' }}">
Active
</a>
<a href="{{ route('admin.customers.index', ['status'=>'inactive', 'search'=>$search ?? '']) }}"
class="btn btn-danger {{ ($status ?? '') == 'inactive' ? 'active' : '' }}">
Inactive
</a>
<a href="{{ route('admin.customers.index') }}"
class="btn btn-secondary {{ empty($status) ? 'active' : '' }}">
All
</a>
</div>
</div>
<div class="d-flex justify-content-between align-items-center mb-3">
<h4>Customer List</h4>
<a href="{{ route('admin.customers.add') }}" class="btn btn-success">
<i class="bi bi-plus-circle"></i> Add Customer
</a>
</div>
{{-- TABLE --}}
<div class="table-responsive">
<table class="table table-bordered align-middle">
<thead class="table-light">
<tr>
<th>Customer Info</th>
<th>Customer ID</th>
<th>Create Date</th>
<th>Status</th>
<th width="120">Actions</th>
</tr>
</thead>
<tbody>
@forelse($customers as $c)
<tr>
{{-- CUSTOMER INFO --}}
<td>
<div class="d-flex align-items-center">
{{-- Avatar --}}
<div class="rounded-circle bg-primary text-white d-flex align-items-center justify-content-center me-3"
style="width:45px; height:45px; font-size:18px;">
{{ strtoupper(substr($c->customer_name,0,1)) }}
</div>
<div>
<strong>{{ $c->customer_name }}</strong><br>
{{-- Customer Type --}}
@if($c->customer_type == 'premium')
<span class="badge bg-purple">Premium Customer</span>
@else
<span class="badge bg-secondary">Regular Customer</span>
@endif
<div class="text-muted">{{ $c->email }}</div>
<div class="text-muted">{{ $c->mobile_no }}</div>
<div class="text-muted">{{ $c->orders->count() }} orders</div>
<div class="text-muted">
{{ number_format($c->orders->sum('ttl_amount'), 2) }} total
</div>
</div>
</div>
</td>
{{-- CUSTOMER ID --}}
<td>{{ $c->customer_id }}</td>
{{-- CREATED DATE --}}
<td>{{ $c->created_at ? $c->created_at->format('d-m-Y') : '-' }}</td>
{{-- STATUS --}}
<td>
@if($c->status === 'active')
<span class="badge bg-success">Active</span>
@else
<span class="badge bg-danger">Inactive</span>
@endif
</td>
{{-- ACTION BUTTONS --}}
<td>
{{-- VIEW --}}
<a href="{{ route('admin.customers.view', $c->id) }}"
class="btn btn-sm btn-primary">
<i class="bi bi-eye"></i>
</a>
{{-- TOGGLE STATUS --}}
<form action="{{ route('admin.customers.status', $c->id) }}"
method="POST" style="display:inline-block;">
@csrf
<button class="btn btn-sm btn-warning" title="Toggle Status">
<i class="bi bi-power"></i>
</button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="5" class="text-center text-muted">
No customers found.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
@endsection