diff --git a/app/Http/Controllers/WebsiteController.php b/app/Http/Controllers/WebsiteController.php index e47b70a..a1321e3 100644 --- a/app/Http/Controllers/WebsiteController.php +++ b/app/Http/Controllers/WebsiteController.php @@ -131,7 +131,7 @@ class WebsiteController extends Controller } - public function careerSingle($id) + public function careerSingle($id) { $data['career'] = Career::findorFail($id); @@ -272,61 +272,78 @@ class WebsiteController extends Controller public function getCost(Request $request) { - $data['costss'] = $this->costCalculatorService->findAll($request); - foreach ($data['costss'] as $value) { - $id = $value->id; + $costs = $this->costCalculatorService->findAll($request); + + if ($costs->isEmpty()) { + return view("client.raffles.errors.404"); } + + $id = $costs->last()->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; + ])->find($id); + + if (!$cost) { + return view("client.raffles.errors.404"); + } + $program = Program::find($request->program_id); + + if (!$program) { + return view("client.raffles.errors.404"); + } $getBreakdown = function ($stayTypeTitle) use ($cost) { - $living = optional($cost->stayTypeLiving->firstWhere('title', $stayTypeTitle))->pivot; + $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; + $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, + 'yearly' => $living->yearly ?? 0, ], 'accomodation' => [ 'monthly' => $accomodation->monthly ?? 0, - 'yearly' => $accomodation->yearly ?? 0, + 'yearly' => $accomodation->yearly ?? 0, ], 'onetime' => [ - 'visa' => $onetime->visa ?? 0, - 'biometrics' => $onetime->biometrics ?? 0, - 'sevis' => $onetime->sevis ?? 0, + '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), + '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), + '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'), + $data = [ + 'costs' => $costs, + 'fee' => $program, + 'title' => 'View Cost Calculation', + 'cost' => $cost, + 'breakdowns' => [ + 'alone' => $getBreakdown('Alone'), + 'with_spouse' => $getBreakdown('With Spouse'), + 'with_spouse_and_child' => $getBreakdown('With Spouse and Child'), + ], ]; return view('client.raffles.pages.cost-result', $data); } + public function thankyouPage(Request $r) { $data = new \stdClass(); diff --git a/public/raffles/assets/images/404/404.png b/public/raffles/assets/images/404/404.png new file mode 100644 index 0000000..22c2c40 Binary files /dev/null and b/public/raffles/assets/images/404/404.png differ diff --git a/resources/views/client/raffles/errors/404.blade.php b/resources/views/client/raffles/errors/404.blade.php index ceac484..12671e1 100644 --- a/resources/views/client/raffles/errors/404.blade.php +++ b/resources/views/client/raffles/errors/404.blade.php @@ -1,12 +1,17 @@ - - -
- - - -