mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
Relocate all 14 files from the catch-all app/Space namespace into proper locations: data providers to Support/Formatters, installation utilities to Services/Installation, PDF utils to Services/Pdf, module/update classes to Services/Module and Services/Update, SiteApi trait to Traits, and helpers to Support. Extract ~1,400 lines of business logic from 8 fat models (Invoice, Payment, Estimate, RecurringInvoice, Company, Customer, Expense, User) into 9 new service classes with constructor injection. Controllers now depend on services instead of calling static model methods. Shared item/tax creation logic consolidated into DocumentItemService.
59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Support\Formatters;
|
|
|
|
use Carbon\Carbon;
|
|
|
|
class DateFormatter
|
|
{
|
|
protected static $formats = [
|
|
[
|
|
'carbon_format' => 'Y M d',
|
|
'moment_format' => 'YYYY MMM DD',
|
|
],
|
|
[
|
|
'carbon_format' => 'd M Y',
|
|
'moment_format' => 'DD MMM YYYY',
|
|
],
|
|
[
|
|
'carbon_format' => 'd/m/Y',
|
|
'moment_format' => 'DD/MM/YYYY',
|
|
],
|
|
[
|
|
'carbon_format' => 'd.m.Y',
|
|
'moment_format' => 'DD.MM.YYYY',
|
|
],
|
|
[
|
|
'carbon_format' => 'd-m-Y',
|
|
'moment_format' => 'DD-MM-YYYY',
|
|
],
|
|
[
|
|
'carbon_format' => 'm/d/Y',
|
|
'moment_format' => 'MM/DD/YYYY',
|
|
],
|
|
[
|
|
'carbon_format' => 'Y/m/d',
|
|
'moment_format' => ' YYYY/MM/DD',
|
|
],
|
|
[
|
|
'carbon_format' => 'Y-m-d',
|
|
'moment_format' => 'YYYY-MM-DD',
|
|
],
|
|
];
|
|
|
|
public static function get_list()
|
|
{
|
|
$new = [];
|
|
|
|
foreach (static::$formats as $format) {
|
|
$new[] = [
|
|
'display_date' => Carbon::now()->translatedFormat($format['carbon_format']),
|
|
'carbon_format_value' => $format['carbon_format'],
|
|
'moment_format_value' => $format['moment_format'],
|
|
];
|
|
}
|
|
|
|
return $new;
|
|
}
|
|
}
|