add controllers, servoices
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Finance;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class FinancialSchoolYearService
|
||||
{
|
||||
public function listYears(?string $fallbackYear = null): array
|
||||
{
|
||||
$years = DB::table('invoices')
|
||||
->select('school_year')
|
||||
->whereNotNull('school_year')
|
||||
->distinct()
|
||||
->orderBy('school_year', 'DESC')
|
||||
->pluck('school_year')
|
||||
->map(static fn ($val) => (string) $val)
|
||||
->filter(static fn ($val) => $val !== '')
|
||||
->values()
|
||||
->all();
|
||||
|
||||
if (empty($years) && !empty($fallbackYear)) {
|
||||
$years[] = (string) $fallbackYear;
|
||||
}
|
||||
|
||||
return $years;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user