加入歌手狀態 20250506
This commit is contained in:
parent
668908f67a
commit
2a7d6fd9aa
@ -23,6 +23,7 @@ class ArtistDataImport implements ToModel, WithHeadingRow
|
|||||||
{
|
{
|
||||||
$name = trim($row['名稱'] ?? '');
|
$name = trim($row['名稱'] ?? '');
|
||||||
$category = trim($row['類別'] ?? '未定義');
|
$category = trim($row['類別'] ?? '未定義');
|
||||||
|
$enable = trim($row['狀態'] ?? 1);
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
$this->failCount++;
|
$this->failCount++;
|
||||||
return null;
|
return null;
|
||||||
@ -31,7 +32,8 @@ class ArtistDataImport implements ToModel, WithHeadingRow
|
|||||||
try {
|
try {
|
||||||
Artist::firstOrCreate(
|
Artist::firstOrCreate(
|
||||||
['name' => $name],
|
['name' => $name],
|
||||||
['category' => ArtistCategory::tryFrom($category) ?? ArtistCategory::Unset]
|
['category' => ArtistCategory::tryFrom($category) ?? ArtistCategory::Unset],
|
||||||
|
['enable' => $enable],
|
||||||
);
|
);
|
||||||
$this->successCount++;
|
$this->successCount++;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
@ -23,6 +23,7 @@ class ArtistForm extends Component
|
|||||||
public array $fields = [
|
public array $fields = [
|
||||||
'category' =>'unset',
|
'category' =>'unset',
|
||||||
'name' =>'',
|
'name' =>'',
|
||||||
|
'enable' => true,
|
||||||
];
|
];
|
||||||
public $selectedCategory = []; // 表單中選到的權限
|
public $selectedCategory = []; // 表單中選到的權限
|
||||||
|
|
||||||
|
@ -114,6 +114,7 @@ final class ArtistTable extends PowerGridComponent
|
|||||||
->add('phonetic_abbr')
|
->add('phonetic_abbr')
|
||||||
->add('pinyin_abbr')
|
->add('pinyin_abbr')
|
||||||
->add('strokes_abbr')
|
->add('strokes_abbr')
|
||||||
|
->add('enable')
|
||||||
->add('created_at_formatted', fn (Artist $model) => Carbon::parse($model->created_at)->format('Y-m-d H:i:s'));
|
->add('created_at_formatted', fn (Artist $model) => Carbon::parse($model->created_at)->format('Y-m-d H:i:s'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,6 +134,7 @@ final class ArtistTable extends PowerGridComponent
|
|||||||
$column[]=Column::make(__('artists.name.phinetic'), 'phonetic_abbr')->sortable()->searchable();
|
$column[]=Column::make(__('artists.name.phinetic'), 'phonetic_abbr')->sortable()->searchable();
|
||||||
$column[]=Column::make(__('artists.name.pinyin'), 'pinyin_abbr')->sortable()->searchable();
|
$column[]=Column::make(__('artists.name.pinyin'), 'pinyin_abbr')->sortable()->searchable();
|
||||||
$column[]=Column::make(__('artists.name.strokes'), 'strokes_abbr')->sortable()->searchable();
|
$column[]=Column::make(__('artists.name.strokes'), 'strokes_abbr')->sortable()->searchable();
|
||||||
|
$column[]=Column::make(__('artists.enable'), 'enable')->toggleable(hasPermission: $this->canEdit, trueLabel: 'yes', falseLabel: 'no');
|
||||||
$column[]=Column::make('Created at', 'created_at_formatted', 'created_at')->sortable()->hidden(true, false);
|
$column[]=Column::make('Created at', 'created_at_formatted', 'created_at')->sortable()->hidden(true, false);
|
||||||
$column[]=Column::action(__('artists.actions'));
|
$column[]=Column::action(__('artists.actions'));
|
||||||
|
|
||||||
@ -182,6 +184,7 @@ final class ArtistTable extends PowerGridComponent
|
|||||||
Filter::inputText('phonetic_abbr')->placeholder(__('artists.name.phinetic')),
|
Filter::inputText('phonetic_abbr')->placeholder(__('artists.name.phinetic')),
|
||||||
Filter::inputText('pinyin_abbr')->placeholder(__('artists.name.pinyin')),
|
Filter::inputText('pinyin_abbr')->placeholder(__('artists.name.pinyin')),
|
||||||
Filter::number('strokes_abbr')->thousands('.')->decimal(','),
|
Filter::number('strokes_abbr')->thousands('.')->decimal(','),
|
||||||
|
Filter::boolean('enable')->label('✅', '❌'),
|
||||||
Filter::datetimepicker('created_at'),
|
Filter::datetimepicker('created_at'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ class Artist extends Model
|
|||||||
'phonetic_abbr',
|
'phonetic_abbr',
|
||||||
'pinyin_abbr',
|
'pinyin_abbr',
|
||||||
'strokes_abbr',
|
'strokes_abbr',
|
||||||
|
'enable',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function casts(): array
|
protected function casts(): array
|
||||||
|
@ -19,6 +19,7 @@ return new class extends Migration
|
|||||||
$table->string('phonetic_abbr')->comment('歌星注音');
|
$table->string('phonetic_abbr')->comment('歌星注音');
|
||||||
$table->string('pinyin_abbr')->comment('歌星拼音');
|
$table->string('pinyin_abbr')->comment('歌星拼音');
|
||||||
$table->integer('strokes_abbr')->comment('歌星筆劃');
|
$table->integer('strokes_abbr')->comment('歌星筆劃');
|
||||||
|
$table->tinyInteger('enable')->default(1)->comment('狀態'); // 1,可看,0,不可看
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ return [
|
|||||||
'name.phinetic' => '注音',
|
'name.phinetic' => '注音',
|
||||||
'name.pinyin' => '拼音',
|
'name.pinyin' => '拼音',
|
||||||
'name.strokes' => '筆劃',
|
'name.strokes' => '筆劃',
|
||||||
|
'enable' => '狀態',
|
||||||
|
|
||||||
'select_category' =>'選擇類別',
|
'select_category' =>'選擇類別',
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
option-value="value"
|
option-value="value"
|
||||||
/>
|
/>
|
||||||
<x-wireui:input label="{{__('artists.name')}}" wire:model.defer="fields.name" />
|
<x-wireui:input label="{{__('artists.name')}}" wire:model.defer="fields.name" />
|
||||||
|
<x-wireui:toggle label="{{__('artists.enable')}}" wire:model.defer="fields.enable" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<x-slot name="footer">
|
<x-slot name="footer">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user