feat: Enhance cost calculator functionality with new cost retrieval route and result display
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user