mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-15 05:00:49 +08:00
medal add priority
This commit is contained in:
@@ -34,6 +34,7 @@ class MedalResource extends Resource
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -82,6 +83,12 @@ class MedalResource extends Resource
|
||||
->numeric()
|
||||
->default(0)
|
||||
,
|
||||
Forms\Components\TextInput::make('priority')
|
||||
->label(__('label.priority'))
|
||||
->helperText(__('label.priority_help'))
|
||||
->numeric()
|
||||
->default(0)
|
||||
,
|
||||
Forms\Components\Textarea::make('description')
|
||||
->label(__('label.description'))
|
||||
,
|
||||
@@ -107,13 +114,12 @@ class MedalResource extends Resource
|
||||
|
||||
Tables\Columns\TextColumn::make('duration')->label(__('label.medal.duration')),
|
||||
|
||||
Tables\Columns\TextColumn::make('inventory')
|
||||
Tables\Columns\TextColumn::make('inventoryText')
|
||||
->label(__('medal.fields.inventory'))
|
||||
->formatStateUsing(fn ($record) => $record->inventory ?? nexus_trans('label.infinite'))
|
||||
,
|
||||
Tables\Columns\TextColumn::make('users_count')->label(__('medal.fields.users_count')),
|
||||
Tables\Columns\TextColumn::make('priority')->label(__('label.priority')),
|
||||
])
|
||||
->defaultSort('id', 'desc')
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
@@ -122,7 +128,9 @@ class MedalResource extends Resource
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
])
|
||||
->modifyQueryUsing(fn (Builder $query) => $query->orderBy("priority", 'desc')->orderBy('id', 'desc'))
|
||||
;
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
|
||||
@@ -18,7 +18,7 @@ class Medal extends NexusModel
|
||||
protected $fillable = [
|
||||
'name', 'description', 'image_large', 'image_small', 'price', 'duration', 'get_type',
|
||||
'display_on_medal_page', 'sale_begin_time', 'sale_end_time', 'inventory', 'bonus_addition_factor',
|
||||
'gift_fee_factor',
|
||||
'gift_fee_factor', 'priority'
|
||||
];
|
||||
|
||||
public $timestamps = true;
|
||||
@@ -48,6 +48,11 @@ class Medal extends NexusModel
|
||||
return nexus_trans("medal.get_types." . $this->get_type);
|
||||
}
|
||||
|
||||
public function getInventoryTextAttribute(): string
|
||||
{
|
||||
return $this->inventory ?? nexus_trans("label.infinite");
|
||||
}
|
||||
|
||||
public function getDurationTextAttribute($value): string
|
||||
{
|
||||
if ($this->duration > 0) {
|
||||
|
||||
Reference in New Issue
Block a user