diff --git a/Modules/CostCalculator/app/Services/CostCalculatorService.php b/Modules/CostCalculator/app/Services/CostCalculatorService.php index 136dcee..a040396 100644 --- a/Modules/CostCalculator/app/Services/CostCalculatorService.php +++ b/Modules/CostCalculator/app/Services/CostCalculatorService.php @@ -3,6 +3,7 @@ namespace Modules\CostCalculator\Services; use Modules\CostCalculator\Models\CostCalculator; +use Modules\CourseFinder\Models\Program; class CostCalculatorService { @@ -13,20 +14,12 @@ class CostCalculatorService $query->where('country_id', $request->country_id); } - if ($request->filled('programlevel_id')) { - $query->where("programlevel_id", $request->programlevel_id); + if ($request->filled('stay_type_id')) { + $query->where("stay_type_id", $request->stay_type_id); } if ($request->filled('program_id')) { - $query->where("program_id", $request->program_id); - } - - if ($request->filled('living_status_id')) { - $query->where("living_status_id", $request->living_status_id); - } - - if ($request->filled('status')) { - $query->where('status', $request->status); + Program::where('status', 1)-> where('id', $request->program_id)->get(); } })->latest()->paginate(10)->withQueryString(); diff --git a/app/Http/Controllers/WebsiteController.php b/app/Http/Controllers/WebsiteController.php index 2382e27..330e024 100644 --- a/app/Http/Controllers/WebsiteController.php +++ b/app/Http/Controllers/WebsiteController.php @@ -10,6 +10,8 @@ use Modules\CCMS\Models\Institution; use Modules\CCMS\Models\Page; use Modules\CCMS\Models\Service; use Modules\CCMS\Models\Test; +use Modules\CostCalculator\Models\CostCalculator; +use Modules\CostCalculator\Models\StayType; use Modules\CourseFinder\Models\Coop; use Modules\CourseFinder\Models\Program; use Modules\CourseFinder\Models\ProgramLevel; @@ -243,13 +245,65 @@ class WebsiteController extends Controller public function costCalculator(Request $request) { $data['programs'] = $this->programService->findAll($request); + $data['programss'] = Program::where('status', 1)->pluck('title', 'id'); $data['countryOptions'] = Country::where('status', 1)->where('parent_id', null)->pluck('title', 'id'); $data['programLevelOptions'] = ProgramLevel::where('status', 1)->pluck('title', 'id'); $data['intakeOptions'] = Program::INTAKE; $data['coopOptions'] = Coop::where('status', 1)->pluck('title', 'id'); $data['testOptions'] = Test::where('status', 1)->where('parent_id', null)->pluck('title', 'id'); - $data['statusOptions'] = config('constants.page_status_options'); + $data['livingStatusOptions'] = StayType::where('status', 1)->pluck('title', 'id'); + return view("client.raffles.pages.cost-calculator", $data); } + + public function getCost(Request $request, $id) + { + $cost = CostCalculator::with([ + 'stayTypeLiving', + 'stayTypeAccomodation', + 'stayTypeOnetime', + 'stayTypeService' + ])->findOrFail($id); + + $data['title'] = 'View Cost Calculation'; + $data['cost'] = $cost; + + $getBreakdown = function ($stayTypeTitle) use ($cost) { + $living = optional($cost->stayTypeLiving->firstWhere('title', $stayTypeTitle))->pivot; + $accomodation = optional($cost->stayTypeAccomodation->firstWhere('title', $stayTypeTitle))->pivot; + $onetime = optional($cost->stayTypeOnetime->firstWhere('title', $stayTypeTitle))->pivot; + $service = optional($cost->stayTypeService->firstWhere('title', $stayTypeTitle))->pivot; + + return [ + 'living' => [ + 'monthly' => $living->monthly ?? 0, + 'yearly' => $living->yearly ?? 0, + ], + 'accomodation' => [ + 'monthly' => $accomodation->monthly ?? 0, + 'yearly' => $accomodation->yearly ?? 0, + ], + 'onetime' => [ + 'visa' => $onetime->visa ?? 0, + 'biometrics' => $onetime->biometrics ?? 0, + 'sevis' => $onetime->sevis ?? 0, + 'application' => $onetime->application ?? 0, + 'total' => ($onetime->visa ?? 0) + ($onetime->biometrics ?? 0) + ($onetime->sevis ?? 0) + ($onetime->application ?? 0), + ], + 'service' => [ + 'flight_ticket' => $service->flight_ticket ?? 0, + 'insurance' => $service->insurance ?? 0, + 'extra' => $service->extra ?? 0, + 'total' => ($service->flight_ticket ?? 0) + ($service->insurance ?? 0) + ($service->extra ?? 0), + ] + ]; + }; + + $data['breakdowns'] = [ + 'alone' => $getBreakdown('Alone'), + 'with_spouse' => $getBreakdown('With Spouse'), + 'with_spouse_and_child' => $getBreakdown('With Spouse and Child'), + ]; + } } diff --git a/resources/views/client/raffles/layouts/app.blade.php b/resources/views/client/raffles/layouts/app.blade.php index a4d34a4..e546a73 100644 --- a/resources/views/client/raffles/layouts/app.blade.php +++ b/resources/views/client/raffles/layouts/app.blade.php @@ -49,7 +49,8 @@ - + @stack('css') + Raffles Educare @@ -97,6 +98,7 @@ + @stack('js')
diff --git a/resources/views/client/raffles/pages/cost-calculator.blade.php b/resources/views/client/raffles/pages/cost-calculator.blade.php index a2af845..bfc4905 100644 --- a/resources/views/client/raffles/pages/cost-calculator.blade.php +++ b/resources/views/client/raffles/pages/cost-calculator.blade.php @@ -1,4 +1,120 @@ @extends('client.raffles.layouts.app') + +@push('css') + +@endpush + @section('content')
@@ -13,315 +129,147 @@
-
+
-
+
- {{--
- @csrf - - - - --}} - -
- -
-

Choose items to find the total cost

-
Which country are you planning to study - in?
- -
- @foreach ($countryOptions as $id => $country) - - @endforeach -
+
+ -
-

Choose items to find the total cost

-
Which level are you applying for?
+ -
- @foreach ($programLevelOptions as $id => $level) - - @endforeach -
-
- -
-

Choose items to find the total cost

-
Are you going alone or with a dependent? -
- -
-
-
-
- -

Alone

-
+ +
+

Which country are you planning to study in?

+
+
+ @foreach ($countries as $country) +
+ + +
+ @endforeach
- -
- + +
+
-
-
-

Choose items to find the total cost

-
Cost of Living
- -
-
-
-
- -

UK £829 / £9948

-
+ +
+

Are you going alone or with a dependent?

+
+
+ @foreach ($livingStatusOptions as $key => $status) +
+ + +
+ @endforeach
- -
- +
+ +
-
-
-

Choose items to find the total cost

-
Accomodation cost per year:
+ +
+

Do you want to include other services?

-
-
- +
+ +
- -
- + +
+ +
-
-
-

Choose items to find the total cost

-
Non-Refundable onetime cost in - processing:
+ +
+

Which Level are you applying for?

-
-
- +
+ @foreach ($programLevelOptions as $level) + + @endforeach
- -
- + +
+ +
-
-
-

Choose items to find the total cost

-
Do you want to include other services? -
+ +
+

Which Program are you applying for?

-
-
-
-
- -

Flighr Ticket

-
+
+
+ @foreach ($programss as $key => $program) + + @endforeach
- -
- + +
+ +
-
- -
- - -
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
-
- -
-
+
- {{-- --}} -
-
+ {{--

Total Cost

- - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + +
S.N.SelectMax PriceSelectMax Price
1Bachelors$13000/year
2Bachelors$13000/year
3Bachelors$13000/year
4Bachelors$13000/year
5Bachelors$13000/year
-
+
--}}
@@ -329,27 +277,75 @@
@endsection - -{{-- @push('js') +@push('js') -@endpush --}} +@endpush