feat: add quarter field to company history items with localization support, enhancing data organization and user experience
This commit is contained in:
@@ -26,6 +26,16 @@ class CompanyHistoryItemForm
|
||||
];
|
||||
}
|
||||
|
||||
public static function quarterOptions(): array
|
||||
{
|
||||
return [
|
||||
'Q1' => __('company_history.quarter_q1'),
|
||||
'Q2' => __('company_history.quarter_q2'),
|
||||
'Q3' => __('company_history.quarter_q3'),
|
||||
'Q4' => __('company_history.quarter_q4'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function colorPresets(): array
|
||||
{
|
||||
return [
|
||||
@@ -52,6 +62,13 @@ class CompanyHistoryItemForm
|
||||
->minValue(1900)
|
||||
->maxValue(2100),
|
||||
|
||||
Select::make('quarter')
|
||||
->label(__('company_history.quarter_field'))
|
||||
->options(self::quarterOptions())
|
||||
->default('Q1')
|
||||
->required()
|
||||
->native(false),
|
||||
|
||||
TextInput::make('title')
|
||||
->label(__('company_history.title_field'))
|
||||
->required()
|
||||
|
||||
+7
-1
@@ -25,6 +25,12 @@ class CompanyHistoryItemsTable
|
||||
->sortable()
|
||||
->alignCenter(),
|
||||
|
||||
TextColumn::make('quarter')
|
||||
->label(__('company_history.quarter_field'))
|
||||
->badge()
|
||||
->sortable()
|
||||
->alignCenter(),
|
||||
|
||||
ColorColumn::make('color')
|
||||
->label(__('company_history.color_field')),
|
||||
|
||||
@@ -88,7 +94,7 @@ class CompanyHistoryItemsTable
|
||||
->label(__('company_history.force_delete')),
|
||||
]),
|
||||
])
|
||||
->defaultSort('sort_order', 'asc')
|
||||
->defaultSort('year', 'asc')
|
||||
->reorderable('sort_order');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,11 @@ class CompanyHistoryItem extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, HasTranslations;
|
||||
|
||||
public const QUARTERS = ['Q1', 'Q2', 'Q3', 'Q4'];
|
||||
|
||||
protected $fillable = [
|
||||
'year',
|
||||
'quarter',
|
||||
'title',
|
||||
'content',
|
||||
'color',
|
||||
@@ -43,7 +46,10 @@ class CompanyHistoryItem extends Model
|
||||
|
||||
public function scopeOrdered($query)
|
||||
{
|
||||
return $query->orderBy('sort_order', 'asc')->orderBy('year', 'asc');
|
||||
return $query
|
||||
->orderBy('year', 'asc')
|
||||
->orderByRaw("CASE quarter WHEN 'Q1' THEN 1 WHEN 'Q2' THEN 2 WHEN 'Q3' THEN 3 WHEN 'Q4' THEN 4 ELSE 5 END")
|
||||
->orderBy('sort_order', 'asc');
|
||||
}
|
||||
|
||||
public function getResolvedPositionAttribute(): string
|
||||
|
||||
Reference in New Issue
Block a user