Files
new_raffles/Modules/CostCalculator/app/Services/CostCalculatorService.php
Subash 165012ea56 feat: Add CostCalculator module with CRUD functionality and frontend integration
- Created new module for CostCalculator with necessary routes and controllers.
- Implemented views for creating, editing, and displaying costs.
- Added form partials for cost input with validation.
- Integrated living status options in the form.
- Developed frontend logic for cost calculation steps with dynamic UI updates.
- Included necessary assets (JS and SCSS) for styling and functionality.
- Updated constants for living status options.
- Enhanced existing client-side cost calculator page with new features.
2025-08-13 17:58:49 +05:45

54 lines
1.6 KiB
PHP

<?php
namespace Modules\CostCalculator\Services;
use Modules\CostCalculator\Models\CostCalculator;
class CostCalculatorService
{
public function findAll($request)
{
return CostCalculator::when($request, function ($query) use ($request) {
if ($request->filled('country_id')) {
$query->whereRelation('institution', 'country_id', $request->country_id);
}
if ($request->filled('institution_id')) {
$query->where("institution_id", $request->institution_id);
}
if ($request->filled('programlevel_id')) {
$query->where("programlevel_id", $request->programlevel_id);
}
if ($request->filled('intake_id')) {
$intakeId = $request->intake_id;
$query->whereJsonContains('intakes', $intakeId);
}
if ($request->filled('status')) {
$query->where('status', $request->status);
}
if ($request->filled('search')) {
$search = $request->search;
$query->where('title', 'like', "%{$search}%");
}
if ($request->filled('location')) {
$location = $request->location;
$query->where('location', 'like', "%{$location}%");
}
})->latest()->paginate(10)->withQueryString();
}
public function pluck(callable $query = null)
{
$baseQuery = CostCalculator::query();
if (is_callable($query)) {
$query($baseQuery);
}
return $baseQuery->pluck('title', 'id');
}
}