feat: Enhance cost calculator functionality with new cost retrieval route and result display

This commit is contained in:
2025-08-18 17:00:40 +05:45
parent ba055ce495
commit 6b4a9f1ebe
7 changed files with 261 additions and 19 deletions

View File

@@ -18,10 +18,6 @@ class CostCalculatorService
$query->where("stay_type_id", $request->stay_type_id);
}
if ($request->filled('program_id')) {
Program::where('status', 1)-> where('id', $request->program_id)->get();
}
})->latest()->paginate(10)->withQueryString();
}

View File

@@ -28,7 +28,7 @@
<div class="text-center">
<p class="mb-0 fs-5 test-muted"><i>Estimated Cost Calculation For
{{ $cost->country?->title ?? 'N/A' }}</i> (<strong
{{ $cost->country?->title ?? 'N/A' }}</i> (<strong
class="text-capitalize">{{ str_replace('_', ' ', $type) }}</strong>)
</p>
</div>

View File

@@ -19,5 +19,6 @@ Route::get('destination/{alias}', [WebsiteController::class, 'countrySingle'])->
Route::get('/home/resources', [WebsiteController::class, 'resources']);
Route::get('getCoursesList', [ProgramController::class, 'getCoursesList'])->name('program.getCoursesList');
Route::post('enquiry', [EnquiryController::class, 'store'])->name('enquiry.store');
Route::get('getCost', [WebsiteController::class, 'getCost'])->name('cost.getCost');
Route::get('{parent}/{slug?}', [WebsiteController::class, 'loadPage'])->name('page.load');

View File

@@ -12,6 +12,7 @@ use Modules\CCMS\Models\Service;
use Modules\CCMS\Models\Test;
use Modules\CostCalculator\Models\CostCalculator;
use Modules\CostCalculator\Models\StayType;
use Modules\CostCalculator\Services\CostCalculatorService;
use Modules\CourseFinder\Models\Coop;
use Modules\CourseFinder\Models\Program;
use Modules\CourseFinder\Models\ProgramLevel;
@@ -21,9 +22,11 @@ class WebsiteController extends Controller
{
private $path;
protected $programService;
public function __construct(ProgramService $programService)
protected $costCalculatorService;
public function __construct(ProgramService $programService, CostCalculatorService $costCalculatorService)
{
$this->programService = $programService;
$this->costCalculatorService = $costCalculatorService;
$headerMenus = getAllHeaderMenusWithChildren();
$footerMenus = getAllFooterMenusWithChildren();
$tests = Test::where('status', 1)->where('parent_id', null)->get();
@@ -257,15 +260,19 @@ class WebsiteController extends Controller
return view("client.raffles.pages.cost-calculator", $data);
}
public function getCost(Request $request, $id)
public function getCost(Request $request)
{
$cost = CostCalculator::with([
$data['costss'] = $this->costCalculatorService->findAll($request);
foreach ($data['costss'] as $value) {
$id = $value->id;
}
$cost = CostCalculator::with([
'stayTypeLiving',
'stayTypeAccomodation',
'stayTypeOnetime',
'stayTypeService'
])->findOrFail($id);
$data['fee'] = Program::where('id', $request->program_id)->first();
$data['title'] = 'View Cost Calculation';
$data['cost'] = $cost;
@@ -305,5 +312,7 @@ class WebsiteController extends Controller
'with_spouse' => $getBreakdown('With Spouse'),
'with_spouse_and_child' => $getBreakdown('With Spouse and Child'),
];
return view('client.raffles.pages.cost-result', $data);
}
}

View File

@@ -144,7 +144,7 @@
<button data-step="4">Program</button>
</div>
<form id="multiStepForm">
<form id="multiStepForm" method="GET" action="{{ route('cost.getCost') }}">
<!-- Step 1: Select Country -->
<div class="tab-pane active" data-step="0">
@@ -153,9 +153,9 @@
<div class="d-flex flex-wrap">
@foreach ($countries as $country)
<div class="form-check country-card me-3 mb-3">
<input class="form-check-input" type="radio" name="country"
value="{{ $country->id }}" id="country_{{ $country->id }}">
<label class="form-check-label" for="country_{{ $country->id }}">
<input class="form-check-input" type="radio" name="country_id"
value="{{ $country->id }}" id="{{ $country->id }}">
<label class="form-check-label" for="{{ $country->id }}">
{{ $country->title }}
</label>
</div>
@@ -176,7 +176,7 @@
<div class="d-flex flex-wrap">
@foreach ($livingStatusOptions as $key => $status)
<div class="form-check status-card me-3 mb-3">
<input class="form-check-input" type="radio" name="status_type"
<input class="form-check-input" type="radio" name="status_type_id"
value="{{ $key }}" id="status_type_{{ $key }}">
<label class="form-check-label" for="status_type_{{ $key }}">
{{ $status }}
@@ -214,8 +214,7 @@
<div class="form-group">
@foreach ($programLevelOptions as $level)
<input type="radio" name="program_level" id="program_level_id"
value="program_level_id"> <label
<input type="radio" name="" id="" value=""> <label
for="program_level_id">{{ $level }}</label>
@endforeach
</div>
@@ -233,7 +232,7 @@
<div class="form-group">
<div class="d-flex flex-wrap">
@foreach ($programss as $key => $program)
<select name="country_id" class="form-control" required>
<select name="program_id" class="form-control" required>
<option value="">Select Program</option>
<option value="{{ $key }}">{{ $program }}</option>
</select>

View File

@@ -0,0 +1,237 @@
@extends('client.raffles.layouts.app')
@push('css')
<style>
.a4-page {
width: 210mm;
/* A4 width */
min-height: 297mm;
/* A4 height */
margin: 20px auto;
padding: 10mm 20mm;
background: #fff;
box-shadow: 0 0 12px rgba(0, 0, 0, 0.15);
border-radius: 12px;
page-break-after: always;
/* Ensures each card starts on a new page when printing */
}
@media print {
body {
background: #fff;
}
.a4-page {
box-shadow: none;
margin: 0;
border-radius: 0;
page-break-after: always;
}
}
.a4-page .card {
font-family: "Segoe UI", Roboto, Arial, sans-serif;
color: #333;
}
.a4-page h6 {
margin-top: 20px;
padding-bottom: 8px;
border-bottom: 2px solid #e9ecef;
}
.a4-page table {
font-size: 14px;
}
.a4-page .badge {
border-radius: 12px;
}
</style>
@endpush
@section('content')
<div class="container">
<div class="container-fluid">
<div class="row justify-content-center">
<div class="col-lg-12">
@foreach ($breakdowns as $type => $breakdown)
<div class="a4-page">
{{-- <div class="card shadow-lg border-0 rounded-4"> --}}
<div class="bg-warning-subtle position-relative">
<div class="card-body text-center py-10">
<a class="navbar-brand p-0" href="{{ url('/') }}" rel="home">
<span class="navbar-brand-inner">
<img src="{{ asset(setting('logo')) }}" alt="raffle logo" />
</span>
</a>
</div>
</div>
<div class="text-center">
<p class="mb-0 fs-5 test-muted"><i>Estimated Cost Calculation For
{{ $cost->country?->title ?? 'N/A' }}</i> (<strong
class="text-capitalize">{{ strtoupper(str_replace('_', ' ', $type)) }}</strong>)
</p>
</div>
<!-- Body -->
<div class="card-body p-4">
<!-- Tution Fee -->
<h6 class="fw-bold mt-4 text-primary">Tution Fee</h6>
<div class="table-responsive">
<table
class="table table-sm table-bordered table-striped shadow-sm rounded align-middle text-center small">
<thead>
<tr class="fw-bold text-uppercase text-end small">
<th></th>
<th>Yearly</th>
</tr>
</thead>
<tbody>
<tr>
<td class="fw-semibold text-muted">{{ $fee['title'] }}</td>
<td class="text-end">
{{ $fee['fee'] }}
</td>
</tr>
</tbody>
</table>
</div>
<!-- Tution Fee -->
<!-- Living & Accommodation -->
<h6 class="fw-bold mt-30 text-primary">Recurring Costs</h6>
<div class="table-responsive">
<table
class="table table-sm table-bordered table-striped shadow-sm rounded align-middle text-center small">
<thead>
<tr class="fw-bold text-uppercase text-end small">
<th></th>
<th>Monthly</th>
<th>Yearly</th>
</tr>
</thead>
<tbody>
<tr>
<td class="fw-semibold text-muted">Living Cost</td>
<td class="text-end">{{ $breakdown['living']['monthly'] }}</td>
<td class="text-end">{{ $breakdown['living']['yearly'] }}</td>
</tr>
<tr>
<td class="fw-semibold text-muted">Accommodation Cost</td>
<td class="text-end">{{ $breakdown['accomodation']['monthly'] }}</td>
<td class="text-end">{{ $breakdown['accomodation']['yearly'] }}</td>
</tr>
<tr class="table-success">
<td class="fw-bold text-uppercase">Total Recurring</td>
<td class="fw-bold text-end">
<span class="badge bg-success fs-6 px-2 py-1">
{{ $breakdown['living']['monthly'] + $breakdown['accomodation']['monthly'] }}
</span>
</td>
<td class="fw-bold text-end">
<span class="badge bg-success fs-6 px-2 py-1">
{{ $breakdown['living']['yearly'] + $breakdown['accomodation']['yearly'] }}
</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Living & Accommodation -->
<!-- One-time Costs -->
<h6 class="fw-bold mt-30 text-primary">One-time Costs</h6>
<div class="table-responsive">
<table
class="table table-sm table-hover table-striped border rounded shadow-sm align-middle small">
<tbody>
<tr>
<td class="fw-semibold text-muted">Visa</td>
<td class="text-end">{{ $breakdown['onetime']['visa'] }}</td>
</tr>
<tr>
<td class="fw-semibold text-muted">Biometrics</td>
<td class="text-end">{{ $breakdown['onetime']['biometrics'] }}</td>
</tr>
<tr>
<td class="fw-semibold text-muted">SEVIS</td>
<td class="text-end">{{ $breakdown['onetime']['sevis'] }}</td>
</tr>
<tr>
<td class="fw-semibold text-muted">Application</td>
<td class="text-end">{{ $breakdown['onetime']['application'] }}</td>
</tr>
<tr class="table-success">
<td class="fw-bold text-uppercase">Total One-time</td>
<td class="fw-bold text-end">
<span class="badge bg-success fs-6 px-2 py-1">
{{ $breakdown['onetime']['total'] }}
</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Service Costs -->
<h6 class="fw-bold mt-30 text-primary">Service Costs</h6>
<div class="table-responsive">
<table
class="table table-sm table-hover table-striped border rounded shadow-sm align-middle small">
<tbody>
<tr>
<td class="fw-semibold text-muted">Flight Ticket</td>
<td class="text-end">{{ $breakdown['service']['flight_ticket'] }}</td>
</tr>
<tr>
<td class="fw-semibold text-muted">Insurance</td>
<td class="text-end">{{ $breakdown['service']['insurance'] }}</td>
</tr>
<tr>
<td class="fw-semibold text-muted">Extra</td>
<td class="text-end">{{ $breakdown['service']['extra'] }}</td>
</tr>
<tr class="table-success">
<td class="fw-bold text-uppercase">Total Service</td>
<td class="fw-bold text-end">
<span class="badge bg-success fs-6 px-2 py-1">
{{ $breakdown['service']['total'] }}
</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Overall -->
<div class="table-responsive mt-4">
<table
class="table table-sm table-bordered shadow-sm rounded-4 text-center align-middle small">
<tbody>
<tr class="table-warning align-middle">
<td class="fw-bold text-uppercase">
<strong>Overall Estimated Cost</strong>
<div class="small fst-italic text-muted">
(Excluding Recurring Costs)
</div>
</td>
<td class="text-end">
<strong>{{ $breakdown['service']['total'] + $breakdown['onetime']['total'] + $fee['fee'] }}</strong>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
{{-- </div> --}}
@endforeach
</div>
</div>
</div>
</div>
@endsection

View File

@@ -19,7 +19,7 @@
@include('client.raffles.parts.testimonial-video')
@include('client.raffles.parts.testimonial-text')
<div class="dot-break"> </div> -->
<div class="dot-break"> </div>
</div>
</section>