mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
fix more modcomment
This commit is contained in:
@@ -41,6 +41,12 @@ class IconResource extends Resource
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Textarea::make('tip')
|
||||
->default(nexus_trans('label.icon.desc'))
|
||||
->disabled()
|
||||
->columnSpanFull()
|
||||
->rows(18)
|
||||
,
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label(__('label.name'))
|
||||
->required()
|
||||
|
||||
@@ -8,7 +8,7 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateIcon extends CreateRecord
|
||||
{
|
||||
protected static string $view = 'filament.resources.system.category-icon-resource.pages.create-record';
|
||||
// protected static string $view = 'filament.resources.system.category-icon-resource.pages.create-record';
|
||||
|
||||
protected static string $resource = IconResource::class;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class EditIcon extends EditRecord
|
||||
|
||||
protected static string $resource = IconResource::class;
|
||||
|
||||
protected static string $view = 'filament.resources.system.category-icon-resource.pages.edit-record';
|
||||
// protected static string $view = 'filament.resources.system.category-icon-resource.pages.edit-record';
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
@@ -22,6 +22,12 @@ class EditIcon extends EditRecord
|
||||
];
|
||||
}
|
||||
|
||||
protected function mutateFormDataBeforeFill(array $data): array
|
||||
{
|
||||
$data['tip'] = nexus_trans('label.icon.desc');
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getViewData(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Repositories\HitAndRunRepository;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Infolists\Infolist;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables;
|
||||
@@ -19,6 +20,8 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Filament\Infolists;
|
||||
use Filament\Infolists\Components;
|
||||
|
||||
class ExamUserResource extends Resource
|
||||
{
|
||||
@@ -138,6 +141,96 @@ class ExamUserResource extends Resource
|
||||
]);
|
||||
}
|
||||
|
||||
public static function infolist(Infolist $infolist): Infolist
|
||||
{
|
||||
return $infolist
|
||||
->schema([
|
||||
Components\Grid::make(2)->schema([
|
||||
Components\Group::make([
|
||||
Infolists\Components\TextEntry::make('id'),
|
||||
Infolists\Components\TextEntry::make('statusText')
|
||||
->label(__("label.status"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('uid')
|
||||
->formatStateUsing(fn ($record) => username_for_admin($record->uid))
|
||||
->label(__("label.username"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('exam.name')
|
||||
// ->formatStateUsing(fn ($record) => $record->torrent->name)
|
||||
->label(__("label.exam.label"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('begin')
|
||||
->label(__("label.begin"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('end')
|
||||
->label(__("label.end"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('isDoneText')
|
||||
->label(__("label.exam_user.is_done"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('created_at')
|
||||
->label(__("label.created_at"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('updated_at')
|
||||
->label(__("label.updated_at"))
|
||||
,
|
||||
])
|
||||
->columnSpan(1)
|
||||
->columns(2)
|
||||
,
|
||||
Components\Group::make([
|
||||
Components\Grid::make(3) // 3 列的网格
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('header1')->label('Header 1'),
|
||||
Infolists\Components\TextEntry::make('header2')->label('Header 2'),
|
||||
Infolists\Components\TextEntry::make('header3')->label('Header 3'),
|
||||
]),
|
||||
Components\Grid::make(3) // 数据行
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('data1')->getStateUsing(fn ($record) => $record->data1),
|
||||
Infolists\Components\TextEntry::make('data2')->getStateUsing(fn ($record) => $record->data2),
|
||||
Infolists\Components\TextEntry::make('data3')->getStateUsing(fn ($record) => $record->data3),
|
||||
]),
|
||||
// 更多数据行...
|
||||
Components\Grid::make(3) // 数据行
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('data1')->getStateUsing(fn ($record) => $record->data4),
|
||||
Infolists\Components\TextEntry::make('data2')->getStateUsing(fn ($record) => $record->data5),
|
||||
Infolists\Components\TextEntry::make('data3')->getStateUsing(fn ($record) => $record->data6),
|
||||
]),
|
||||
])->columnSpan(1),
|
||||
]),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
// private static function buildProgressTable(): array
|
||||
// {
|
||||
// $exam = $record->exam;
|
||||
// $passTransKey = $exam->getPassResultTransKey('pass');
|
||||
// $notPassTransKey = $exam->getPassResultTransKey('not_pass');
|
||||
// $result = [];
|
||||
// $result[] = Components\Grid::make(4) // 4 列的网格
|
||||
// ->schema([
|
||||
// Infolists\Components\TextEntry::make('index')->label(__('label.exam.index_required_label')),
|
||||
// Infolists\Components\TextEntry::make('require')->label(__('label.exam.index_required_value')),
|
||||
// Infolists\Components\TextEntry::make('current')->label(__('label.exam.index_current_value')),
|
||||
// Infolists\Components\TextEntry::make('result')->label(__('label.exam.index_result')),
|
||||
// ]);
|
||||
// foreach($record->progressFormatted as $key => $index) {
|
||||
// $result[] = Components\Grid::make(4) // 4 列的网格
|
||||
// ->schema([
|
||||
// Infolists\Components\TextEntry::make('index'.$key)->label($index['index_formatted']),
|
||||
// Infolists\Components\TextEntry::make('require'.$key)->label($index['require_value_formatted']),
|
||||
// Infolists\Components\TextEntry::make('current'.$key)->label($index['current_value_formatted']),
|
||||
// Infolists\Components\TextEntry::make('result'.$key)->label($index['passed'] ? __($passTransKey) : __($notPassTransKey)),
|
||||
// ]);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return $result;
|
||||
// }
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->with(['user', 'exam']);
|
||||
|
||||
@@ -15,7 +15,7 @@ class ViewExamUser extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ExamUserResource::class;
|
||||
|
||||
protected static string $view = 'filament.resources.user.exam-user-resource.pages.detail';
|
||||
// protected static string $view = 'filament.resources.user.exam-user-resource.pages.detail';
|
||||
|
||||
private function getDetailCardData(): array
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ use App\Models\Snatch;
|
||||
use App\Models\User;
|
||||
use App\Models\UserBanLog;
|
||||
use App\Models\UserMeta;
|
||||
use App\Models\UserModifyLog;
|
||||
use App\Models\UsernameChangeLog;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -286,13 +287,11 @@ class UserRepository extends BaseRepository
|
||||
'new' => $formatSize ? mksize($new) : $new,
|
||||
'reason' => $reason,
|
||||
], 'en');
|
||||
$modCommentText = date('Y-m-d') . " - $modCommentText";
|
||||
do_log("user: $uid, $modCommentText", 'alert');
|
||||
$update = [
|
||||
$sourceField => $new,
|
||||
'modcomment' => NexusDB::raw("if(modcomment = '', '$modCommentText', concat_ws('\n', '$modCommentText', modcomment))"),
|
||||
// 'modcomment' => NexusDB::raw("if(modcomment = '', '$modCommentText', concat_ws('\n', '$modCommentText', modcomment))"),
|
||||
];
|
||||
|
||||
$locale = $targetUser->locale;
|
||||
$fieldLabel = nexus_trans("user.labels.$sourceField", [], $locale);
|
||||
$msg = nexus_trans('message.field_value_change_message_body', [
|
||||
@@ -309,7 +308,7 @@ class UserRepository extends BaseRepository
|
||||
'msg' => $msg,
|
||||
'added' => Carbon::now(),
|
||||
];
|
||||
NexusDB::transaction(function () use ($uid, $sourceField, $old, $new, $update, $message) {
|
||||
NexusDB::transaction(function () use ($uid, $sourceField, $old, $new, $update, $message, $modCommentText) {
|
||||
$affectedRows = User::query()
|
||||
->where('id', $uid)
|
||||
->where($sourceField, $old)
|
||||
@@ -319,6 +318,12 @@ class UserRepository extends BaseRepository
|
||||
throw new \RuntimeException("Change fail, affected rows != 1($affectedRows)");
|
||||
}
|
||||
Message::query()->insert($message);
|
||||
UserModifyLog::query()->insert([
|
||||
'user_id' => $uid,
|
||||
'content' => $modCommentText,
|
||||
'created_at' => Carbon::now(),
|
||||
'updated_at' => Carbon::now(),
|
||||
]);
|
||||
});
|
||||
$this->clearCache($targetUser);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user