From 5a350b5eda0b63562a902128188fd2797d41d27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BClent=20Sakarya?= Date: Mon, 11 Sep 2023 22:12:34 +0300 Subject: [PATCH] =?UTF-8?q?log=20kay=C4=B1tlar=C4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Activity/Activity.php | 44 ---- app/Http/Controllers/Admin.php | 3 +- .../Admin/AdminDetailController.php | 17 +- app/Http/Controllers/Dashboard.php | 3 +- .../Controllers/User/UserDetailController.php | 5 +- app/Models/Permission.php | 19 +- app/Models/Permissiongroup.php | 19 +- app/Models/Role.php | 19 +- app/Models/Settings.php | 18 +- app/Models/User.php | 20 +- app/Models/Usertag.php | 20 +- composer.json | 2 +- composer.lock | 205 +++++------------- config/activitylog.php | 52 ----- config/user-activity.php | 21 ++ .../2020_11_20_100001_create_log_table.php | 35 +++ ...06_15_102844_create_activity_log_table.php | 27 --- ...add_event_column_to_activity_log_table.php | 22 -- ...atch_uuid_column_to_activity_log_table.php | 22 -- lang/tr/admin-navigation.php | 3 +- resources/css/app.css | 2 +- resources/views/activity/index.blade.php | 97 --------- resources/views/activity/user.blade.php | 97 --------- resources/views/admins/detail.blade.php | 54 ++--- .../partials/navigation-admin.blade.php | 12 +- resources/views/users/detail.blade.php | 10 +- routes/admin.php | 9 +- routes/web.php | 1 - 28 files changed, 156 insertions(+), 702 deletions(-) delete mode 100644 app/Http/Controllers/Activity/Activity.php delete mode 100644 config/activitylog.php create mode 100644 config/user-activity.php create mode 100644 database/migrations/2020_11_20_100001_create_log_table.php delete mode 100644 database/migrations/2023_06_15_102844_create_activity_log_table.php delete mode 100644 database/migrations/2023_06_15_102845_add_event_column_to_activity_log_table.php delete mode 100644 database/migrations/2023_06_15_102846_add_batch_uuid_column_to_activity_log_table.php delete mode 100644 resources/views/activity/index.blade.php delete mode 100644 resources/views/activity/user.blade.php diff --git a/app/Http/Controllers/Activity/Activity.php b/app/Http/Controllers/Activity/Activity.php deleted file mode 100644 index 08329c4..0000000 --- a/app/Http/Controllers/Activity/Activity.php +++ /dev/null @@ -1,44 +0,0 @@ -toArray(); - $models = ActivityModel::pluck('subject_type')->toArray(); - $events = array_unique($events); - $models = array_unique($models); - - $activities = ActivityModel::where('log_name', 'admin')->get(); - $activities = PaginateCollection::paginate($activities, 25); - return view('activity.index', [ - 'activities' => $activities, - 'events' => $events, - 'models' => $models - ]); - } - - public function users(): View - { - $events = ActivityModel::pluck('event')->toArray(); - $models = ActivityModel::pluck('subject_type')->toArray(); - $events = array_unique($events); - $models = array_unique($models); - - $activities = ActivityModel::where('log_name', 'user')->get(); - $activities = PaginateCollection::paginate($activities, 5); - return view('activity.user', [ - 'activities' => $activities, - 'events' => $events, - 'models' => $models - ]); - } -} diff --git a/app/Http/Controllers/Admin.php b/app/Http/Controllers/Admin.php index c0d0f9d..fcd7a38 100644 --- a/app/Http/Controllers/Admin.php +++ b/app/Http/Controllers/Admin.php @@ -5,14 +5,13 @@ use App\Http\Controllers\Controller; use App\Models\User; use Illuminate\View\View; -use Spatie\Activitylog\Models\Activity; class Admin extends Controller { public function index(): View { - $activities = Activity::limit('1'); + $activities = ''; return view('admin', ['activities' => $activities]); } diff --git a/app/Http/Controllers/Admin/AdminDetailController.php b/app/Http/Controllers/Admin/AdminDetailController.php index d46a60d..061ecdf 100644 --- a/app/Http/Controllers/Admin/AdminDetailController.php +++ b/app/Http/Controllers/Admin/AdminDetailController.php @@ -49,10 +49,13 @@ public function show(User $user): View $rolePermissions = !empty($userCustomPermissions) ? array_merge($rolePermissions, $userCustomPermissions) : $rolePermissions; + $auth_activities = User::select('last_login_at', 'last_login_ip')->where('id', $user->id)->get(); + return view('admins.detail', [ 'user' => $user, 'basePermissions' => $basePermissions, - 'rolePermissions' => $rolePermissions + 'rolePermissions' => $rolePermissions, + 'auth_activities' => $auth_activities ]); } @@ -61,8 +64,6 @@ public function show(User $user): View */ public function status(Request $request, User $user) { - $ip = request()->ip(); - $authuser = auth()->user()->name; if ($request->ajax() && $request->has('ids')) { foreach (UserStatus::cases() as $userStatus) { @@ -74,8 +75,6 @@ public function status(Request $request, User $user) $user->status = $status; $user->save(); - $statusname = UserStatus::getTitle($status); - return response()->json(['status' => 'success']); } @@ -90,8 +89,6 @@ public function status(Request $request, User $user) */ public function passwordReset(Request $request, User $user) { - $ip = request()->ip(); - $authuser = auth()->user()->name; if ($request->ajax() && $request->has('user_id')) { if($user->status == UserStatus::ACTIVE) { @@ -118,9 +115,6 @@ public function passwordReset(Request $request, User $user) public function changeEmail(Request $request, User $user) { - $ip = request()->ip(); - $authuser = auth()->user()->name; - if ($request->email !== $user->email && $user instanceof MustVerifyEmail) { $user->email = $request->email; $user->email_verified_at = null; @@ -143,9 +137,6 @@ public function changeEmail(Request $request, User $user) public function verifyEmail(Request $request, User $user) { - $ip = request()->ip(); - $authuser = auth()->user()->name; - if ($request->ajax() && $request->has('user_id')) { $status = $user->sendEmailVerificationNotification(); diff --git a/app/Http/Controllers/Dashboard.php b/app/Http/Controllers/Dashboard.php index eab8f83..d6e2001 100644 --- a/app/Http/Controllers/Dashboard.php +++ b/app/Http/Controllers/Dashboard.php @@ -5,13 +5,12 @@ use App\Http\Controllers\Controller; use App\Models\User; use Illuminate\View\View; -use Spatie\Activitylog\Models\Activity; class Dashboard extends Controller { public function index(): View { - $activities = Activity::limit('1'); + $activities = ''; return view('index', compact('activities')); } diff --git a/app/Http/Controllers/User/UserDetailController.php b/app/Http/Controllers/User/UserDetailController.php index a9c3fa6..584b1d1 100644 --- a/app/Http/Controllers/User/UserDetailController.php +++ b/app/Http/Controllers/User/UserDetailController.php @@ -17,7 +17,6 @@ use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\Redirect; use Illuminate\View\View; -use Spatie\Activitylog\Models\Activity; class UserDetailController extends Controller { @@ -43,7 +42,7 @@ public function show(User $user): View $tags = Usertag::where('status', Status::ACTIVE)->get(); $selectedTag = $user->usertags->pluck('id')->toArray(); $userCustomPermissions = $user->getAllPermissions()->pluck('id')->toArray(); - $activities = Activity::where('causer_id', $user->id)->get(); + $auth_activities = User::select('last_login_at', 'last_login_ip')->where('id', $user->id)->get(); foreach ($user->roles as $key => $role) { $permissions = Permission::withWhereHas('group', fn ($query) => $query->where('type', $role->type))->get(); @@ -63,7 +62,7 @@ public function show(User $user): View 'selectedTag' => $selectedTag, 'basePermissions' => $basePermissions, 'rolePermissions' => $rolePermissions, - 'activities' => $activities + 'auth_activities' => $auth_activities ]); } diff --git a/app/Models/Permission.php b/app/Models/Permission.php index e00e2c2..529c139 100644 --- a/app/Models/Permission.php +++ b/app/Models/Permission.php @@ -5,13 +5,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Spatie\Permission\Models\Permission as PermissionModel; use App\Models\Permissiongroup; -use Spatie\Activitylog\Traits\LogsActivity; -use Spatie\Activitylog\LogOptions; -use Spatie\Activitylog\Models\Activity; +use Haruncpi\LaravelUserActivity\Traits\Loggable; class Permission extends PermissionModel { - use HasFactory, LogsActivity; + use HasFactory, Loggable; protected $table = 'permissions'; @@ -22,19 +20,6 @@ class Permission extends PermissionModel 'guard_name' ]; - public function tapActivity(Activity $activity, string $eventName) - { - $authuser = !empty(auth()->user()->name) ?auth()->user()->name : 'Super Admin'; - $activity->description = __("permission.activity.message.{$eventName}", ['authuser' => $authuser]); - } - - public function getActivitylogOptions(): LogOptions - { - return LogOptions::defaults() - ->useLogName('admin') - ->logOnly(['name', 'group_id', 'text']); - } - public function group() { return $this->belongsTo(Permissiongroup::class, 'group_id', 'id'); diff --git a/app/Models/Permissiongroup.php b/app/Models/Permissiongroup.php index 72b8379..5bc4a94 100644 --- a/app/Models/Permissiongroup.php +++ b/app/Models/Permissiongroup.php @@ -6,13 +6,11 @@ use Illuminate\Database\Eloquent\Model; use App\Enums\UserType; use App\Models\Permission; -use Spatie\Activitylog\Traits\LogsActivity; -use Spatie\Activitylog\LogOptions; -use Spatie\Activitylog\Models\Activity; +use Haruncpi\LaravelUserActivity\Traits\Loggable; class Permissiongroup extends Model { - use HasFactory, LogsActivity; + use HasFactory, Loggable; protected $table = 'permissiongroups'; @@ -26,19 +24,6 @@ class Permissiongroup extends Model 'type' => UserType::class ]; - public function tapActivity(Activity $activity, string $eventName) - { - $authuser = !empty(auth()->user()->name) ? auth()->user()->name : 'Super Admin'; - $activity->description = __("permissiongroup.activity.message.{$eventName}", ['authuser' => $authuser]); - } - - public function getActivitylogOptions(): LogOptions - { - return LogOptions::defaults() - ->useLogName('admin') - ->logOnly(['name', 'type', 'desc']); - } - public function permission() { return $this->hasMany(Permission::class, 'group_id', 'id'); diff --git a/app/Models/Role.php b/app/Models/Role.php index c2955d0..528d944 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -5,14 +5,11 @@ use App\Enums\UserType; use Spatie\Permission\Models\Role as RoleModel; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Illuminate\Database\Eloquent\Model; -use Spatie\Activitylog\Traits\LogsActivity; -use Spatie\Activitylog\LogOptions; -use Spatie\Activitylog\Models\Activity; +use Haruncpi\LaravelUserActivity\Traits\Loggable; class Role extends RoleModel { - use HasFactory, LogsActivity; + use HasFactory, Loggable; protected $fillable = [ 'name', @@ -25,16 +22,4 @@ class Role extends RoleModel 'type' => UserType::class ]; - public function tapActivity(Activity $activity, string $eventName) - { - $authuser = !empty(auth()->user()->name) ? auth()->user()->name : 'Super Admin'; - $activity->description = __("role.activity.message.{$eventName}", ['authuser' => $authuser]); - } - - public function getActivitylogOptions(): LogOptions - { - return LogOptions::defaults() - ->useLogName('admin') - ->logOnly(['name', 'type', 'desc']); - } } diff --git a/app/Models/Settings.php b/app/Models/Settings.php index fd33e54..9285063 100644 --- a/app/Models/Settings.php +++ b/app/Models/Settings.php @@ -4,13 +4,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -use Spatie\Activitylog\Traits\LogsActivity; -use Spatie\Activitylog\LogOptions; -use Spatie\Activitylog\Models\Activity; +use Haruncpi\LaravelUserActivity\Traits\Loggable; class Settings extends Model { - use HasFactory, LogsActivity; + use HasFactory, Loggable; protected $table = 'settings'; @@ -24,16 +22,4 @@ class Settings extends Model 'updated_at' => 'datetime' ]; - public function tapActivity(Activity $activity, string $eventName) - { - $authuser = !empty(auth()->user()->name) ? auth()->user()->name : 'Super Admin'; - $activity->description = __("role.activity.message.{$eventName}", ['authuser' => $authuser]); - } - - public function getActivitylogOptions(): LogOptions - { - return LogOptions::defaults() - ->useLogName('admin') - ->logOnly(['key', 'value']); - } } diff --git a/app/Models/User.php b/app/Models/User.php index 25133d1..1bf569a 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -5,7 +5,6 @@ use App\Enums\UserStatus; use App\Enums\UserType; use App\Models\Usertag; -use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; @@ -13,13 +12,11 @@ use Laravel\Fortify\TwoFactorAuthenticatable; use Laravel\Sanctum\HasApiTokens; use Spatie\Permission\Traits\HasRoles; -use Spatie\Activitylog\Traits\LogsActivity; -use Spatie\Activitylog\LogOptions; -use Spatie\Activitylog\Models\Activity; +use Haruncpi\LaravelUserActivity\Traits\Loggable; class User extends Authenticatable implements MustVerifyEmail { - use HasApiTokens, HasFactory, Notifiable, TwoFactorAuthenticatable, HasRoles, LogsActivity; + use HasApiTokens, HasFactory, Notifiable, TwoFactorAuthenticatable, HasRoles; /** * The attributes that are mass assignable. @@ -68,19 +65,6 @@ class User extends Authenticatable implements MustVerifyEmail 'settings' => 'array', ]; - public function tapActivity(Activity $activity, string $eventName) - { - $authuser = !empty(auth()->user()->name) ? auth()->user()->name : 'Super Admin'; - $activity->description = __("user.activity.message.{$eventName}", ['authuser' => $authuser]); - } - - public function getActivitylogOptions(): LogOptions - { - return LogOptions::defaults() - ->useLogName('admin') - ->logOnly(['type', 'status', 'name', 'email', 'email_verified_at', 'password', 'created_by', 'created_by_name', 'terms']); - } - public function usertags() { return $this->belongsToMany(Usertag::class)->withTimestamps(); diff --git a/app/Models/Usertag.php b/app/Models/Usertag.php index 4a44081..b19c2d6 100644 --- a/app/Models/Usertag.php +++ b/app/Models/Usertag.php @@ -5,14 +5,11 @@ use App\Enums\Status; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Log; -use Spatie\Activitylog\Traits\LogsActivity; -use Spatie\Activitylog\LogOptions; -use Spatie\Activitylog\Models\Activity; +use Haruncpi\LaravelUserActivity\Traits\Loggable; class Usertag extends Model { - use HasFactory, LogsActivity; + use HasFactory, Loggable; protected $table = 'usertags'; @@ -32,19 +29,6 @@ class Usertag extends Model 'status' => Status::class, ]; - public function tapActivity(Activity $activity, string $eventName) - { - $authuser = !empty(auth()->user()->name) ? auth()->user()->name : 'Super Admin'; - $activity->description = __("usertag.activity.message.{$eventName}", ['authuser' => $authuser]); - } - - public function getActivitylogOptions(): LogOptions - { - return LogOptions::defaults() - ->useLogName('admin') - ->logOnly(['status', 'name', 'color', 'desc']); - } - public function users() { return $this->belongsToMany(User::class)->withTimestamps(); diff --git a/composer.json b/composer.json index cee63d4..c55730a 100644 --- a/composer.json +++ b/composer.json @@ -7,12 +7,12 @@ "require": { "php": "^8.1", "guzzlehttp/guzzle": "^7.2", + "haruncpi/laravel-user-activity": "^1.0", "laravel/fortify": "^1.17", "laravel/framework": "^10.8", "laravel/sanctum": "^3.2", "laravel/tinker": "^2.8", "opcodesio/log-viewer": "^2.4", - "spatie/laravel-activitylog": "^4.7", "spatie/laravel-permission": "^5.10", "torann/geoip": "^3.0" }, diff --git a/composer.lock b/composer.lock index 2e179d6..5a6c5c3 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "f6a3fa50a3263da122f856f6bc782b50", + "content-hash": "7d630bb65f356499d116baf2e2681da3", "packages": [ { "name": "bacon/bacon-qr-code", @@ -1074,6 +1074,58 @@ ], "time": "2023-08-27T10:19:19+00:00" }, + { + "name": "haruncpi/laravel-user-activity", + "version": "v1.0.6", + "source": { + "type": "git", + "url": "https://github.com/haruncpi/laravel-user-activity.git", + "reference": "5055fd4a03edc39a1eea8d2d1cbdef3ed007da52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/haruncpi/laravel-user-activity/zipball/5055fd4a03edc39a1eea8d2d1cbdef3ed007da52", + "reference": "5055fd4a03edc39a1eea8d2d1cbdef3ed007da52", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Haruncpi\\LaravelUserActivity\\ServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Haruncpi\\LaravelUserActivity\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "cc-by-4.0" + ], + "authors": [ + { + "name": "MD.HARUN-UR-RASHID", + "email": "harun.cox@gmail.com" + } + ], + "description": "Monitor user activity easily!", + "keywords": [ + "activity", + "laravel", + "user" + ], + "support": { + "issues": "https://github.com/haruncpi/laravel-user-activity/issues", + "source": "https://github.com/haruncpi/laravel-user-activity/tree/v1.0.6" + }, + "time": "2023-08-13T04:16:39+00:00" + }, { "name": "laravel/fortify", "version": "v1.17.6", @@ -3468,157 +3520,6 @@ ], "time": "2023-04-15T23:01:58+00:00" }, - { - "name": "spatie/laravel-activitylog", - "version": "4.7.3", - "source": { - "type": "git", - "url": "https://github.com/spatie/laravel-activitylog.git", - "reference": "ec65a478a909b8df1b4f0c3c45de2592ca7639e5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-activitylog/zipball/ec65a478a909b8df1b4f0c3c45de2592ca7639e5", - "reference": "ec65a478a909b8df1b4f0c3c45de2592ca7639e5", - "shasum": "" - }, - "require": { - "illuminate/config": "^8.0 || ^9.0 || ^10.0", - "illuminate/database": "^8.69 || ^9.27 || ^10.0", - "illuminate/support": "^8.0 || ^9.0 || ^10.0", - "php": "^8.0", - "spatie/laravel-package-tools": "^1.6.3" - }, - "require-dev": { - "ext-json": "*", - "orchestra/testbench": "^6.23 || ^7.0 || ^8.0", - "pestphp/pest": "^1.20" - }, - "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.7.3" - }, - "funding": [ - { - "url": "https://spatie.be/open-source/support-us", - "type": "custom" - }, - { - "url": "https://github.com/spatie", - "type": "github" - } - ], - "time": "2023-01-25T17:04:51+00:00" - }, - { - "name": "spatie/laravel-package-tools", - "version": "1.16.1", - "source": { - "type": "git", - "url": "https://github.com/spatie/laravel-package-tools.git", - "reference": "cc7c991555a37f9fa6b814aa03af73f88026a83d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/cc7c991555a37f9fa6b814aa03af73f88026a83d", - "reference": "cc7c991555a37f9fa6b814aa03af73f88026a83d", - "shasum": "" - }, - "require": { - "illuminate/contracts": "^9.28|^10.0", - "php": "^8.0" - }, - "require-dev": { - "mockery/mockery": "^1.5", - "orchestra/testbench": "^7.7|^8.0", - "pestphp/pest": "^1.22", - "phpunit/phpunit": "^9.5.24", - "spatie/pest-plugin-test-time": "^1.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "Spatie\\LaravelPackageTools\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Freek Van der Herten", - "email": "freek@spatie.be", - "role": "Developer" - } - ], - "description": "Tools for creating Laravel packages", - "homepage": "https://github.com/spatie/laravel-package-tools", - "keywords": [ - "laravel-package-tools", - "spatie" - ], - "support": { - "issues": "https://github.com/spatie/laravel-package-tools/issues", - "source": "https://github.com/spatie/laravel-package-tools/tree/1.16.1" - }, - "funding": [ - { - "url": "https://github.com/spatie", - "type": "github" - } - ], - "time": "2023-08-23T09:04:39+00:00" - }, { "name": "spatie/laravel-permission", "version": "5.11.0", diff --git a/config/activitylog.php b/config/activitylog.php deleted file mode 100644 index 5f6afcf..0000000 --- a/config/activitylog.php +++ /dev/null @@ -1,52 +0,0 @@ - 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' => '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'), -]; diff --git a/config/user-activity.php b/config/user-activity.php new file mode 100644 index 0000000..5282a7d --- /dev/null +++ b/config/user-activity.php @@ -0,0 +1,21 @@ + true, // active/inactive all logging + 'middleware' => ['web', 'auth'], + 'route_path' => 'panel/user-activity', + 'admin_panel_path' => 'panel/admin', + 'delete_limit' => 90, // default 7 days + + 'model' => [ + 'user' => "App\Models\User" + ], + + 'log_events' => [ + 'on_create' => true, + 'on_edit' => true, + 'on_delete' => true, + 'on_login' => true, + 'on_lockout' => true + ] +]; diff --git a/database/migrations/2020_11_20_100001_create_log_table.php b/database/migrations/2020_11_20_100001_create_log_table.php new file mode 100644 index 0000000..d812753 --- /dev/null +++ b/database/migrations/2020_11_20_100001_create_log_table.php @@ -0,0 +1,35 @@ +bigIncrements('id'); + $table->bigInteger('user_id')->unsigned(); + $table->dateTime('log_date'); + $table->string('table_name',50)->nullable(); + $table->string('log_type',50); + $table->longText('data'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('logs'); + } +} diff --git a/database/migrations/2023_06_15_102844_create_activity_log_table.php b/database/migrations/2023_06_15_102844_create_activity_log_table.php deleted file mode 100644 index 7c05bc8..0000000 --- a/database/migrations/2023_06_15_102844_create_activity_log_table.php +++ /dev/null @@ -1,27 +0,0 @@ -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')); - } -} diff --git a/database/migrations/2023_06_15_102845_add_event_column_to_activity_log_table.php b/database/migrations/2023_06_15_102845_add_event_column_to_activity_log_table.php deleted file mode 100644 index 7b797fd..0000000 --- a/database/migrations/2023_06_15_102845_add_event_column_to_activity_log_table.php +++ /dev/null @@ -1,22 +0,0 @@ -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'); - }); - } -} diff --git a/database/migrations/2023_06_15_102846_add_batch_uuid_column_to_activity_log_table.php b/database/migrations/2023_06_15_102846_add_batch_uuid_column_to_activity_log_table.php deleted file mode 100644 index 8f7db66..0000000 --- a/database/migrations/2023_06_15_102846_add_batch_uuid_column_to_activity_log_table.php +++ /dev/null @@ -1,22 +0,0 @@ -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'); - }); - } -} diff --git a/lang/tr/admin-navigation.php b/lang/tr/admin-navigation.php index 05e2e5b..b1162ab 100644 --- a/lang/tr/admin-navigation.php +++ b/lang/tr/admin-navigation.php @@ -26,7 +26,6 @@ 'permissions' => 'İzinler', 'permission-groups' => 'İzinler Grupları', 'system-logs' => 'Sistem Kayıtları', - 'admin-logs' => 'Yönetici Kayıtları', - 'user-logs' => 'Kullanıcı Kayıtları', + 'app-logs' => 'Uygulama Kayıtları', 'twofa' => 'İki Faktörlü Doğrulama' ]; diff --git a/resources/css/app.css b/resources/css/app.css index 6cd7d8e..3e53d07 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -537,7 +537,7 @@ div:where(.swal2-container) button:where(.swal2-styled) { .vertical-timeline-element-icon { position: absolute; - top: 0; + top: 5px; left: 120px; } diff --git a/resources/views/activity/index.blade.php b/resources/views/activity/index.blade.php deleted file mode 100644 index cfa0574..0000000 --- a/resources/views/activity/index.blade.php +++ /dev/null @@ -1,97 +0,0 @@ -@extends('layouts.app') -@section('content') - @include('layouts.partials.page-title', ['title' => 'Yönetici Uygulama Kayıtları']) -
-
-
-
-
-
-

Yönetici Hareketleri

- Yöneticilerin uygulama içerisinde yapmış olduğu işlemler -
-
- @foreach ($activities as $activity) -
-
-
- - - -
-

-

{{ $activity->description }}

- {{ $activity->created_at->format('d-m-Y') }}
{{ $activity->created_at->format('H:i:s') }}
-
-
-
-
- @endforeach -
- -
-
-
-
-
-

Kullanıcı Ara

-
-
-
- - -
-
-
-
-
-
-

Eylem

-
-
-
    - @foreach ($events as $event) -
  • -
    - - -
    -
  • - @endforeach -
-
-
-
-
-

Modül

-
-
-
    - @foreach ($models as $key => $model) -
  • -
    - - -
    -
  • - @endforeach -
-
-
-
-
-
-
-
-@endsection diff --git a/resources/views/activity/user.blade.php b/resources/views/activity/user.blade.php deleted file mode 100644 index cdd33f4..0000000 --- a/resources/views/activity/user.blade.php +++ /dev/null @@ -1,97 +0,0 @@ -@extends('layouts.app') -@section('content') - @include('layouts.partials.page-title', ['title' => 'Kullanıcı Uygulama Kayıtları']) -
-
-
-
-
-
-

Kullanıcı Hareketleri

- Kullanıcıların uygulama içerisinde yapmış olduğu işlemler -
-
- @foreach ($activities as $activity) -
-
-
- - - -
-

-

{{ $activity->description }}

- {{ $activity->created_at->format('d-m-Y') }}
{{ $activity->created_at->format('H:i:s') }}
-
-
-
-
- @endforeach -
- -
-
-
-
-
-

Kullanıcı Ara

-
-
-
- - -
-
-
-
-
-
-

Eylem

-
-
-
    - @foreach ($events as $event) -
  • -
    - - -
    -
  • - @endforeach -
-
-
-
-
-

Modül

-
-
-
    - @foreach ($models as $key => $model) -
  • -
    - - -
    -
  • - @endforeach -
-
-
-
-
-
-
-
-@endsection diff --git a/resources/views/admins/detail.blade.php b/resources/views/admins/detail.blade.php index 22a30ec..a0cb098 100644 --- a/resources/views/admins/detail.blade.php +++ b/resources/views/admins/detail.blade.php @@ -116,48 +116,24 @@ class="ri-fingerprint-line">

Oturum Kayıtları

-
-
-
- - - -
-

Başarılı Ödeme

-

Paket ödemesi başarılı bir şekilde gerçekleşti

- 12 Ağustos - 2022
15:30:45
-
-
-
-
-
- - - -
-

Başarısız Ödeme

-

Paket ödemesi gerçekleşmedi

- 07 Temmuz - 2023
15:30:45
-
-
-
-
-
- - - -
-

Paket Değişimi

-

Standart aylık paketten standart yıllık pakete geçiş gerçekleşti.

- 27 Aralık - 2023
15:30:45
+ @foreach ($auth_activities as $auth_activity) +
+
+
+ + + +
+

{{ $auth_activity->last_login_at }} tarihinde + {{ $auth_activity->last_login_ip }} ip adresi üzerinden oturum + açtı +

+
-
+ @endforeach
diff --git a/resources/views/layouts/partials/navigation-admin.blade.php b/resources/views/layouts/partials/navigation-admin.blade.php index 7206a45..c3a16f0 100644 --- a/resources/views/layouts/partials/navigation-admin.blade.php +++ b/resources/views/layouts/partials/navigation-admin.blade.php @@ -89,17 +89,9 @@ class="align-middle">{{ __('admin-navigation.system-logs') }} - @endhasrole diff --git a/resources/views/users/detail.blade.php b/resources/views/users/detail.blade.php index 0a9b8d6..9fb8722 100644 --- a/resources/views/users/detail.blade.php +++ b/resources/views/users/detail.blade.php @@ -63,7 +63,7 @@ class="ri-fingerprint-line">

Hesap Hareketleri

- @foreach ($activities as $activity) + @foreach ($auth_activities as $auth_activity)
@@ -72,10 +72,10 @@ class="vertical-timeline vertical-timeline--animate vertical-timeline--one-colum
-

Başarılı Ödeme

-

Paket ödemesi başarılı bir şekilde gerçekleşti

- 12 Ağustos - 2022
15:30:45
+

{{ $auth_activity->last_login_at }} tarihinde + {{ $auth_activity->last_login_ip }} ip adresi üzerinden oturum + açtı +

diff --git a/routes/admin.php b/routes/admin.php index 88cc4c3..787c65b 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -1,6 +1,5 @@ prefix('panel')->name('panel.')->group(function () { +Route::middleware(['auth', 'auth.session', 'verified', 'panel_settings'])->prefix('panel')->name('panel.')->group(function () { Route::middleware(['adminonly'])->group(function(){ @@ -130,12 +129,8 @@ Route::post('/permission-group/destroy/{permissiongroup}', 'destroy')->name('permission.group.destroy'); }); - Route::controller(Activity::class)->group(function () { - Route::get('/activity/admin', 'index')->name('admin.activity'); - Route::get('/activity/user', 'users')->name('user.activity'); - }); - Route::redirect('/panel/log-viewer', '/panel/log-viewer')->name('system-logs'); + Route::redirect('/panel/user-activity', '/panel/user-activity')->name('app-logs'); Route::prefix('cache')->name('cache.')->group(function () { Route::get('/clear/all', function() { diff --git a/routes/web.php b/routes/web.php index 2595ad7..1284fb0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,7 +4,6 @@ use App\Http\Controllers\Profile\ProfileController; use App\Http\Controllers\Profile\TwoFactorAuthenticationController; use App\Http\Controllers\Setting\SettingController; -use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; use Laravel\Fortify\Events\TwoFactorAuthenticationEvent;