mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
Activity Log
This commit is contained in:
@@ -6,14 +6,13 @@ use Filament\Support\Enums\Width;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Closure;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
use Filament\Tables\Filters\Layout;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PageListSingle extends ManageRecords
|
||||
{
|
||||
protected Width|string|null $maxContentWidth = 'full';
|
||||
|
||||
protected function getTableFiltersLayout(): ?string
|
||||
protected function getTableFiltersLayout(): FiltersLayout
|
||||
{
|
||||
return FiltersLayout::AboveContent;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\ActivityLogs;
|
||||
|
||||
use App\Filament\Resources\System\ActivityLogs\Pages\ManageActivityLogs;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\QueryBuilder;
|
||||
use Filament\Tables\Filters\QueryBuilder\Constraints\DateConstraint;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use UnitEnum;
|
||||
|
||||
class ActivityLogResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Activity::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static string | UnitEnum | null $navigationGroup = 'System';
|
||||
|
||||
protected static ?int $navigationSort = 99;
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.activity_logs');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function getLabel(): ?string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
// subject 是被操作的对象,也是一个关联关系
|
||||
TextColumn::make('subject_type')
|
||||
->label(__("activity-log.subject_type"))
|
||||
,
|
||||
|
||||
TextColumn::make('subject_id')
|
||||
->label(__("activity-log.subject_id"))
|
||||
,
|
||||
|
||||
TextColumn::make('description')
|
||||
->label(__('label.description'))
|
||||
,
|
||||
|
||||
// causer 是操作者,一个关联关系
|
||||
TextColumn::make('causer.username')
|
||||
->label(__('label.operator'))
|
||||
,
|
||||
|
||||
TextColumn::make('created_at')
|
||||
->label(__('label.created_at'))
|
||||
,
|
||||
])
|
||||
->defaultSort('id', 'desc')
|
||||
->filters([
|
||||
Filter::make('created_at_begin')
|
||||
->schema([
|
||||
DateTimePicker::make('created_at_begin')->label(__('label.created_at_begin')),
|
||||
])
|
||||
->query(function (Builder $query, array $data) {
|
||||
return $query
|
||||
->when(
|
||||
$data['created_at_begin'],
|
||||
fn (Builder $query, $value): Builder => $query->where('created_at', '>=', $value),
|
||||
);
|
||||
}),
|
||||
Filter::make('created_at_end')
|
||||
->schema([
|
||||
DateTimePicker::make('created_at_end')->label(__('label.created_at_end')),
|
||||
])
|
||||
->query(function (Builder $query, array $data) {
|
||||
return $query
|
||||
->when(
|
||||
$data['created_at_end'],
|
||||
fn (Builder $query, $value): Builder => $query->where('created_at', '<=', $value),
|
||||
);
|
||||
}),
|
||||
Filter::make('operator')
|
||||
->schema([
|
||||
TextInput::make('operator')->label(__('label.operator')),
|
||||
])
|
||||
->query(function (Builder $query, array $data) {
|
||||
return $query
|
||||
->when(
|
||||
$data['operator'],
|
||||
fn (Builder $query, $value): Builder => $query->whereHas('causer', function (Builder $query) use ($value) {
|
||||
$query->where('username', 'like', "%{$value}%");
|
||||
}),
|
||||
);
|
||||
}),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make('view_properties')
|
||||
->label(__("activity-log.view_properties"))
|
||||
->icon('heroicon-o-information-circle')
|
||||
->color('gray')
|
||||
->schema(function ($record) {
|
||||
$fields = [];
|
||||
// 动态地从 JSON 数据创建 TextEntry
|
||||
// 注意:这里需要确保 $record->properties 是一个数组
|
||||
$properties = $record->properties->toArray();
|
||||
foreach ($properties as $key => $value) {
|
||||
// 如果值是数组或对象,美化输出
|
||||
if (is_array($value) || is_object($value)) {
|
||||
$value = json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||
$fields[] = TextEntry::make($key)->html()->getStateUsing(fn() => "<pre><code>$value</code></pre>");
|
||||
} else {
|
||||
$fields[] = TextEntry::make($key)->label(ucfirst($key));
|
||||
}
|
||||
}
|
||||
return $fields;
|
||||
})
|
||||
->action(null), // 无需执行任何操作
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageActivityLogs::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\ActivityLogs\Pages;
|
||||
|
||||
use App\Filament\PageListSingle;
|
||||
use App\Filament\Resources\System\ActivityLogs\ActivityLogResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageActivityLogs extends PageListSingle
|
||||
{
|
||||
protected static string $resource = ActivityLogResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ModelEventEnum;
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class AgentAllow extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'agent_allowed_family';
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ModelEventEnum;
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class AgentDeny extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'agent_allowed_exception';
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class AudioCodec extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'audiocodecs';
|
||||
|
||||
protected $fillable = ['name', 'sort_index', 'mode',];
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Avp extends NexusModel
|
||||
{
|
||||
|
||||
use NexusActivityLogTrait;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Category extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'categories';
|
||||
|
||||
protected $fillable = ['mode', 'name', 'class_name', 'image', 'sort_index', 'icon_id'];
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Codec extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'codecs';
|
||||
|
||||
protected $fillable = ['name', 'sort_index', 'mode',];
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class DownloadSpeed extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'downloadspeed';
|
||||
|
||||
protected $fillable = ['name'];
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
use Carbon\Carbon;
|
||||
use Google\Service\Dataproc\RegexValidation;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Exam extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'description', 'begin', 'end', 'duration', 'status', 'is_discovered', 'filters', 'indexes', 'priority',
|
||||
'recurring', 'type', 'success_reward_bonus', 'fail_deduct_bonus', 'max_user_count', 'background_color',
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
use App\Repositories\ExamRepository;
|
||||
|
||||
class ExamUser extends NexusModel
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Icon extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'caticons';
|
||||
|
||||
protected $fillable = ['name', 'folder', 'cssfile', 'multilang', 'secondicon', 'designer', 'comment'];
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Isp extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'isp';
|
||||
|
||||
protected $fillable = ['name'];
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Medal extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
const GET_TYPE_EXCHANGE = 1;
|
||||
|
||||
const GET_TYPE_GRANT = 2;
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Media extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'media';
|
||||
|
||||
protected $fillable = ['name', 'sort_index', 'mode',];
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\MessageTemplateNameEnum;
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class MessageTemplate extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = ['name', 'content', 'language_id'];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class News extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'news';
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Passport\Client;
|
||||
|
||||
class OauthClient extends Client
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (OauthClient $model) {
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
use Laravel\Passport\Client;
|
||||
use Nexus\Database\NexusDB;
|
||||
use Ramsey\Uuid;
|
||||
|
||||
class OauthProvider extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = [
|
||||
'uuid', 'name', 'client_id', 'client_secret', 'authorization_endpoint_url', 'token_endpoint_url',
|
||||
'user_info_endpoint_url', 'id_claim', 'username_claim', 'email_claim', 'enabled', 'priority',
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Poll extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = ['added', 'question', 'option0', 'option1', 'option2', 'option3', 'option4', 'option5'];
|
||||
|
||||
protected $casts = [
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class PollAnswer extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'pollanswers';
|
||||
|
||||
protected $fillable = ['pollid', 'userid', 'selection',];
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Processing extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'processings';
|
||||
|
||||
protected $fillable = ['name', 'sort_index', 'mode',];
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Auth\Permission;
|
||||
use App\Http\Middleware\Locale;
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
use App\Repositories\TagRepository;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
@@ -12,6 +13,8 @@ use Nexus\Database\NexusDB;
|
||||
|
||||
class SearchBox extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
private static array $instances = [];
|
||||
|
||||
private static array $modeOptions = [];
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class SecondIcon extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'secondicons';
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -5,12 +5,15 @@ namespace App\Models;
|
||||
use App\Enums\SeedBoxRecord\IpAsnEnum;
|
||||
use App\Enums\SeedBoxRecord\IsAllowedEnum;
|
||||
use App\Enums\SeedBoxRecord\TypeEnum;
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
use App\Repositories\SeedBoxRepository;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class SeedBoxRecord extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = ['type', 'uid', 'status', 'operator', 'bandwidth', 'ip', 'ip_begin', 'ip_end', 'ip_begin_numeric', 'ip_end_numeric',
|
||||
'comment', 'version', 'is_allowed', 'asn'
|
||||
];
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
use Illuminate\Support\Arr;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class Setting extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = ['name', 'value', 'autoload'];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Source extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = ['name', 'sort_index', 'mode',];
|
||||
|
||||
public static function getLabelName()
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Standard extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = ['name', 'sort_index', 'mode',];
|
||||
|
||||
public static function getLabelName()
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Tag extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Team extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = ['name', 'sort_index', 'mode',];
|
||||
|
||||
public static function getLabelName()
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class Topic extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = ['userid', 'subject', 'locked', 'forumid', 'firstpost', 'lastpost', 'sticky', 'hlcolor', 'views'];
|
||||
|
||||
public function user()
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class TorrentDenyReason extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'torrent_deny_reasons';
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class TorrentState extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = ['global_sp_state', 'deadline', 'begin'];
|
||||
|
||||
protected $table = 'torrents_state';
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class TrackerUrl extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = ['url', 'enabled', 'is_default', 'priority'];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
18
app/Models/Traits/NexusActivityLogTrait.php
Normal file
18
app/Models/Traits/NexusActivityLogTrait.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits;
|
||||
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
trait NexusActivityLogTrait
|
||||
{
|
||||
use LogsActivity;
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnlyDirty()
|
||||
->dontSubmitEmptyLogs()
|
||||
->logAll();
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class UploadSpeed extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $table = 'uploadspeed';
|
||||
|
||||
protected $fillable = ['name'];
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Exceptions\NexusException;
|
||||
use App\Http\Middleware\Locale;
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
use App\Repositories\ExamRepository;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -23,7 +24,7 @@ use NexusPlugin\Permission\Models\UserPermission;
|
||||
|
||||
class User extends Authenticatable implements FilamentUser, HasName
|
||||
{
|
||||
use HasFactory, Notifiable, HasApiTokens;
|
||||
use HasFactory, Notifiable, HasApiTokens, NexusActivityLogTrait;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
@@ -633,7 +634,4 @@ class User extends Authenticatable implements FilamentUser, HasName
|
||||
&& $this->accessToken && $this->accessToken->can($ability);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\NexusActivityLogTrait;
|
||||
|
||||
class UserMeta extends NexusModel
|
||||
{
|
||||
use NexusActivityLogTrait;
|
||||
|
||||
protected $fillable = ['uid', 'meta_key', 'meta_value', 'status', 'deadline'];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
"phpgangsta/googleauthenticator": "dev-master",
|
||||
"rhilip/bencode": "^2.0",
|
||||
"rlanvin/php-ip": "^3.0",
|
||||
"spatie/laravel-activitylog": "^4.10",
|
||||
"stichoza/google-translate-php": "^5.2"
|
||||
},
|
||||
"require-dev": {
|
||||
|
||||
93
composer.lock
generated
93
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "42746b91dd9127753319825b3ad3db54",
|
||||
"content-hash": "282076e99007f806ed211e60021107e0",
|
||||
"packages": [
|
||||
{
|
||||
"name": "anourvalar/eloquent-serialize",
|
||||
@@ -7425,6 +7425,97 @@
|
||||
],
|
||||
"time": "2024-05-17T09:06:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-activitylog",
|
||||
"version": "4.10.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/laravel-activitylog.git",
|
||||
"reference": "bb879775d487438ed9a99e64f09086b608990c10"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-activitylog/zipball/bb879775d487438ed9a99e64f09086b608990c10",
|
||||
"reference": "bb879775d487438ed9a99e64f09086b608990c10",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/config": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
|
||||
"illuminate/database": "^8.69 || ^9.27 || ^10.0 || ^11.0 || ^12.0",
|
||||
"illuminate/support": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
|
||||
"php": "^8.1",
|
||||
"spatie/laravel-package-tools": "^1.6.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-json": "*",
|
||||
"orchestra/testbench": "^6.23 || ^7.0 || ^8.0 || ^9.0 || ^10.0",
|
||||
"pestphp/pest": "^1.20 || ^2.0 || ^3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Spatie\\Activitylog\\ActivitylogServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Spatie\\Activitylog\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Freek Van der Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian De Deyne",
|
||||
"email": "sebastian@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Tom Witkowski",
|
||||
"email": "dev.gummibeer@gmail.com",
|
||||
"homepage": "https://gummibeer.de",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "A very simple activity logger to monitor the users of your website or application",
|
||||
"homepage": "https://github.com/spatie/activitylog",
|
||||
"keywords": [
|
||||
"activity",
|
||||
"laravel",
|
||||
"log",
|
||||
"spatie",
|
||||
"user"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/spatie/laravel-activitylog/issues",
|
||||
"source": "https://github.com/spatie/laravel-activitylog/tree/4.10.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://spatie.be/open-source/support-us",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/spatie",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-06-15T06:59:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-package-tools",
|
||||
"version": "1.92.7",
|
||||
|
||||
52
config/activitylog.php
Normal file
52
config/activitylog.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
* If set to false, no activities will be saved to the database.
|
||||
*/
|
||||
'enabled' => env('ACTIVITY_LOGGER_ENABLED', true),
|
||||
|
||||
/*
|
||||
* When the clean-command is executed, all recording activities older than
|
||||
* the number of days specified here will be deleted.
|
||||
*/
|
||||
'delete_records_older_than_days' => 365,
|
||||
|
||||
/*
|
||||
* If no log name is passed to the activity() helper
|
||||
* we use this default log name.
|
||||
*/
|
||||
'default_log_name' => 'default',
|
||||
|
||||
/*
|
||||
* You can specify an auth driver here that gets user models.
|
||||
* If this is null we'll use the current Laravel auth driver.
|
||||
*/
|
||||
'default_auth_driver' => null,
|
||||
|
||||
/*
|
||||
* If set to true, the subject returns soft deleted models.
|
||||
*/
|
||||
'subject_returns_soft_deleted_models' => false,
|
||||
|
||||
/*
|
||||
* This model will be used to log activity.
|
||||
* It should implement the Spatie\Activitylog\Contracts\Activity interface
|
||||
* and extend Illuminate\Database\Eloquent\Model.
|
||||
*/
|
||||
'activity_model' => \Spatie\Activitylog\Models\Activity::class,
|
||||
|
||||
/*
|
||||
* This is the name of the table that will be created by the migration and
|
||||
* used by the Activity model shipped with this package.
|
||||
*/
|
||||
'table_name' => env('ACTIVITY_LOGGER_TABLE_NAME', 'activity_log'),
|
||||
|
||||
/*
|
||||
* This is the database connection that will be used by the migration and
|
||||
* the Activity model shipped with this package. In case it's not set
|
||||
* Laravel's database.default will be used instead.
|
||||
*/
|
||||
'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'),
|
||||
];
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('log_name')->nullable();
|
||||
$table->text('description');
|
||||
$table->nullableMorphs('subject', 'subject');
|
||||
$table->nullableMorphs('causer', 'causer');
|
||||
$table->json('properties')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('log_name');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddEventColumnToActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->string('event')->nullable()->after('subject_type');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('event');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddBatchUuidColumnToActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->uuid('batch_uuid')->nullable()->after('properties');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('batch_uuid');
|
||||
});
|
||||
}
|
||||
}
|
||||
7
resources/lang/en/activity-log.php
Normal file
7
resources/lang/en/activity-log.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'view_properties' => 'View properties',
|
||||
'subject_type' => 'Model',
|
||||
'subject_id' => 'Model ID',
|
||||
];
|
||||
@@ -48,6 +48,7 @@ return [
|
||||
'user_modify_logs' => 'User modify logs',
|
||||
'message_templates' => 'Message templates',
|
||||
'tracker_url' => 'Tracker URL',
|
||||
'activity_logs' => 'Activity Logs',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
|
||||
7
resources/lang/zh_CN/activity-log.php
Normal file
7
resources/lang/zh_CN/activity-log.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'view_properties' => '查看属性',
|
||||
'subject_type' => '模型',
|
||||
'subject_id' => '模型 ID',
|
||||
];
|
||||
@@ -48,6 +48,7 @@ return [
|
||||
'tracker_url' => 'Tracker URL',
|
||||
'announce_logs' => '汇报记录',
|
||||
'announce_monitor' => '汇报监控',
|
||||
'activity_logs' => '操作日志',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
|
||||
7
resources/lang/zh_TW/activity-log.php
Normal file
7
resources/lang/zh_TW/activity-log.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'view_properties' => '查看屬性',
|
||||
'subject_type' => '模型',
|
||||
'subject_id' => '模型 ID',
|
||||
];
|
||||
@@ -50,6 +50,7 @@ return [
|
||||
'tracker_url' => 'Tracker URL',
|
||||
'announce_logs' => '匯報記錄',
|
||||
'announce_monitor' => '匯報監控',
|
||||
'activity_logs' => '操作日志',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
|
||||
Reference in New Issue
Block a user