add global promotion deadline + fix grane medal

This commit is contained in:
xiaomlove
2022-07-09 18:06:09 +08:00
parent 50759b1cf3
commit afa8cdce99
40 changed files with 1936 additions and 20 deletions

View File

@@ -17,7 +17,7 @@ class CreateExam extends CreateRecord
// dd($data);
$examRep = new ExamRepository();
try {
$examRep->store($data);
$this->record = $examRep->store($data);
$this->notify('success', $this->getCreatedNotificationMessage());
if ($another) {
// Ensure that the form record is anonymized so that relationships aren't loaded.

View File

@@ -23,7 +23,7 @@ class EditExam extends EditRecord
$data = $this->form->getState();
$examRep = new ExamRepository();
try {
$examRep->update($data, $this->record->id);
$this->record = $examRep->update($data, $this->record->id);
$this->notify('success', $this->getSavedNotificationMessage());
$this->redirect($this->getResource()::getUrl('index'));
} catch (\Exception $exception) {

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateMedal extends CreateRecord
{
protected static string $resource = MedalResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}
}

View File

@@ -0,0 +1,81 @@
<?php
namespace App\Filament\Resources\System;
use App\Filament\Resources\System\TorrentStateResource\Pages;
use App\Filament\Resources\System\TorrentStateResource\RelationManagers;
use App\Models\Torrent;
use App\Models\TorrentState;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Nexus\Database\NexusDB;
class TorrentStateResource extends Resource
{
protected static ?string $model = TorrentState::class;
protected static ?string $navigationIcon = 'heroicon-o-speakerphone';
protected static ?string $navigationGroup = 'System';
protected static ?int $navigationSort = 99;
protected static function getNavigationLabel(): string
{
return __('admin.sidebar.torrent_state');
}
public static function getBreadcrumb(): string
{
return self::getNavigationLabel();
}
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('global_sp_state')
->options(Torrent::listPromotionTypes(true))
->label(__('label.torrent_state.global_sp_state'))
->required(),
Forms\Components\DateTimePicker::make('deadline')
->required()
->label(__('label.deadline')),
])->columns(1);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('global_sp_state_text')->label(__('label.torrent_state.global_sp_state')),
Tables\Columns\TextColumn::make('deadline')->label(__('label.deadline')),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make()->after(function () {
do_log("cache_del: global_promotion_state");
NexusDB::cache_del('global_promotion_state');
NexusDB::cache_del('global_promotion_state_deadline');
}),
// Tables\Actions\DeleteAction::make(),
])
->bulkActions([
// Tables\Actions\DeleteBulkAction::make(),
]);
}
public static function getPages(): array
{
return [
'index' => Pages\ManageTorrentStates::route('/'),
];
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Filament\Resources\System\TorrentStateResource\Pages;
use App\Filament\Resources\System\TorrentStateResource;
use Filament\Pages\Actions;
use Filament\Resources\Pages\ManageRecords;
use Nexus\Database\NexusDB;
class ManageTorrentStates extends ManageRecords
{
protected static string $resource = TorrentStateResource::class;
protected function getActions(): array
{
return [
// Actions\CreateAction::make(),
];
}
protected function isTablePaginationEnabled(): bool
{
return false;
}
}