mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-26 13:27:22 +08:00
attendance log
This commit is contained in:
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\User;
|
||||||
|
|
||||||
|
use App\Filament\OptionsTrait;
|
||||||
|
use App\Filament\Resources\User\AttendanceLogResource\Pages;
|
||||||
|
use App\Filament\Resources\User\AttendanceLogResource\RelationManagers;
|
||||||
|
use App\Models\AttendanceLog;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
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;
|
||||||
|
|
||||||
|
class AttendanceLogResource extends Resource
|
||||||
|
{
|
||||||
|
use OptionsTrait;
|
||||||
|
|
||||||
|
protected static ?string $model = AttendanceLog::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-pencil-alt';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'User';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 11;
|
||||||
|
|
||||||
|
protected static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return __('admin.sidebar.attendance_log');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getBreadcrumb(): string
|
||||||
|
{
|
||||||
|
return self::getNavigationLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function form(Form $form): Form
|
||||||
|
{
|
||||||
|
return $form
|
||||||
|
->schema([
|
||||||
|
//
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('uid')->formatStateUsing(fn ($state) => username_for_admin($state)),
|
||||||
|
Tables\Columns\TextColumn::make('date')->label(__('attendance.fields.date'))->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('points')->label(__('attendance.fields.points')),
|
||||||
|
Tables\Columns\IconColumn::make('is_retroactive')
|
||||||
|
->label(__('attendance.fields.is_retroactive'))
|
||||||
|
->boolean(true)
|
||||||
|
,
|
||||||
|
Tables\Columns\TextColumn::make('created_at')->label(__('label.created_at')),
|
||||||
|
])
|
||||||
|
->defaultSort('id', 'desc')
|
||||||
|
->filters([
|
||||||
|
Tables\Filters\Filter::make('id')
|
||||||
|
->form([
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->placeholder('UID')
|
||||||
|
,
|
||||||
|
])->query(function (Builder $query, array $data) {
|
||||||
|
return $query->when($data['id'], fn (Builder $query, $value) => $query->where("uid", $value));
|
||||||
|
})
|
||||||
|
,
|
||||||
|
Tables\Filters\SelectFilter::make('is_retroactive')
|
||||||
|
->options(self::getYesNoOptions())
|
||||||
|
->label(__('attendance.fields.is_retroactive'))
|
||||||
|
,
|
||||||
|
Tables\Filters\Filter::make('date')
|
||||||
|
->form([
|
||||||
|
Forms\Components\DatePicker::make('date')
|
||||||
|
->maxDate(now())
|
||||||
|
->label(__('attendance.fields.date'))
|
||||||
|
,
|
||||||
|
])->query(function (Builder $query, array $data) {
|
||||||
|
return $query->when($data['date'], fn (Builder $query, $value) => $query->where("date", $value));
|
||||||
|
})
|
||||||
|
,
|
||||||
|
Tables\Filters\Filter::make('created_at')
|
||||||
|
->form([
|
||||||
|
Forms\Components\DatePicker::make('created_at')
|
||||||
|
->label(__('label.created_at'))
|
||||||
|
,
|
||||||
|
])->query(function (Builder $query, array $data) {
|
||||||
|
return $query->when($data['created_at'], function (Builder $query, $value) {
|
||||||
|
$begin = Carbon::parse($value)->startOfDay();
|
||||||
|
$end = Carbon::parse($value)->endOfDay();
|
||||||
|
return $query->where("created_at", ">=", $begin)->where('created_at', '<=', $end);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
,
|
||||||
|
])
|
||||||
|
->actions([
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => Pages\ManageAttendanceLogs::route('/'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\User\AttendanceLogResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\PageListSingle;
|
||||||
|
use App\Filament\Resources\User\AttendanceLogResource;
|
||||||
|
use Filament\Pages\Actions;
|
||||||
|
use Filament\Resources\Pages\ManageRecords;
|
||||||
|
|
||||||
|
class ManageAttendanceLogs extends PageListSingle
|
||||||
|
{
|
||||||
|
protected static string $resource = AttendanceLogResource::class;
|
||||||
|
|
||||||
|
protected function getActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,6 +64,8 @@ class AttendanceRepository extends BaseRepository
|
|||||||
'uid' => $attendance->uid,
|
'uid' => $attendance->uid,
|
||||||
'points' => $update['points'],
|
'points' => $update['points'],
|
||||||
'date' => $now->format('Y-m-d'),
|
'date' => $now->format('Y-m-d'),
|
||||||
|
'created_at' => $now,
|
||||||
|
'updated_at' => $now,
|
||||||
];
|
];
|
||||||
AttendanceLog::query()->insert($attendanceLog);
|
AttendanceLog::query()->insert($attendanceLog);
|
||||||
}
|
}
|
||||||
|
|||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('agent_allowed_family', function (Blueprint $table) {
|
||||||
|
$table->string("comment")->nullable(true)->change();
|
||||||
|
});
|
||||||
|
Schema::table('agent_deny_family', function (Blueprint $table) {
|
||||||
|
$table->string("comment")->nullable(true)->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
|
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
|
||||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-04-09');
|
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-04-12');
|
||||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||||
|
|||||||
@@ -6,4 +6,9 @@ return [
|
|||||||
'already_attendance' => 'Already attendance',
|
'already_attendance' => 'Already attendance',
|
||||||
'card_not_enough' => 'Attendance card not enough',
|
'card_not_enough' => 'Attendance card not enough',
|
||||||
'ranking' => "Today's Ranking: <b>:ranking</b> / <b>:counts</b>",
|
'ranking' => "Today's Ranking: <b>:ranking</b> / <b>:counts</b>",
|
||||||
|
'fields' => [
|
||||||
|
'date' => 'Date',
|
||||||
|
'points' => 'Got bonus',
|
||||||
|
'is_retroactive' => 'Is retroactive',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ return [
|
|||||||
'login_log' => '登录记录',
|
'login_log' => '登录记录',
|
||||||
'bonus_log' => '魔力记录',
|
'bonus_log' => '魔力记录',
|
||||||
'torrent_buy_log' => '种子购买',
|
'torrent_buy_log' => '种子购买',
|
||||||
|
'attendance_log' => '签到记录',
|
||||||
],
|
],
|
||||||
'resources' => [
|
'resources' => [
|
||||||
'agent_allow' => [
|
'agent_allow' => [
|
||||||
|
|||||||
@@ -6,4 +6,9 @@ return [
|
|||||||
'already_attendance' => '已经签到',
|
'already_attendance' => '已经签到',
|
||||||
'card_not_enough' => '补签卡不足',
|
'card_not_enough' => '补签卡不足',
|
||||||
'ranking' => '今日签到排名:<b>:ranking</b> / <b>:counts</b>',
|
'ranking' => '今日签到排名:<b>:ranking</b> / <b>:counts</b>',
|
||||||
|
'fields' => [
|
||||||
|
'date' => '日期',
|
||||||
|
'points' => '获得魔力',
|
||||||
|
'is_retroactive' => '是否补签',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -6,5 +6,10 @@ return [
|
|||||||
'already_attendance' => '已經簽到',
|
'already_attendance' => '已經簽到',
|
||||||
'card_not_enough' => '補簽卡不足',
|
'card_not_enough' => '補簽卡不足',
|
||||||
'ranking' => '今日簽到排名:<b>:ranking</b> / <b>:counts</b>',
|
'ranking' => '今日簽到排名:<b>:ranking</b> / <b>:counts</b>',
|
||||||
|
'fields' => [
|
||||||
|
'date' => '日期',
|
||||||
|
'points' => '獲得魔力',
|
||||||
|
'is_retroactive' => '是否補簽',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user