Remove activity log migration files and update FillJsonData seeder to include ActionEventsMigrator. Clean up LoanOrdersMigrator comments for clarity.
This commit is contained in:
64
app/Modules/ActivityLog/ActivityLogModule.php
Normal file
64
app/Modules/ActivityLog/ActivityLogModule.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\ActivityLog;
|
||||||
|
|
||||||
|
use App\Modules\Makeable;
|
||||||
|
use App\Modules\ModuleContract;
|
||||||
|
|
||||||
|
class ActivityLogModule implements ModuleContract
|
||||||
|
{
|
||||||
|
use Makeable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module is enabled
|
||||||
|
*/
|
||||||
|
protected bool $enabled = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if is module enabled
|
||||||
|
*/
|
||||||
|
public function isEnabled(): bool
|
||||||
|
{
|
||||||
|
return $this->enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable module
|
||||||
|
*/
|
||||||
|
public function disable(): void
|
||||||
|
{
|
||||||
|
$this->enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable module
|
||||||
|
*/
|
||||||
|
public function enable(): void
|
||||||
|
{
|
||||||
|
$this->enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if module has a filament resource
|
||||||
|
*/
|
||||||
|
public function hasFilamentResource(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get module composer requirements
|
||||||
|
*/
|
||||||
|
public function getComposerRequirements(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get module composer suggestions
|
||||||
|
*/
|
||||||
|
public function getComposerSuggestions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\ActivityLog\Repositories;
|
||||||
|
|
||||||
|
use App\Modules\ActivityLog\Models\ActivityLog;
|
||||||
|
|
||||||
|
class ActivityLogRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
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'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
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');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
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');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('action_events', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('batch_id')->nullable();
|
||||||
|
$table->unsignedBigInteger('user_id')->nullable()->index();
|
||||||
|
|
||||||
|
$table->string('name')->index();
|
||||||
|
|
||||||
|
$table->string('actionable_type')->nullable()->index();
|
||||||
|
$table->unsignedBigInteger('actionable_id')->nullable()->index();
|
||||||
|
|
||||||
|
$table->string('target_type')->nullable()->index();
|
||||||
|
$table->unsignedBigInteger('target_id')->nullable()->index();
|
||||||
|
|
||||||
|
$table->string('model_type')->nullable()->index();
|
||||||
|
$table->unsignedBigInteger('model_id')->nullable()->index();
|
||||||
|
|
||||||
|
$table->text('fields')->nullable();
|
||||||
|
$table->string('status')->index()->default('finished');
|
||||||
|
$table->text('exception')->nullable();
|
||||||
|
$table->json('original')->nullable();
|
||||||
|
$table->json('changes')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('action_events');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -11,7 +11,7 @@ class FillJsonData extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
$this->seedVisaMasterPaymentOrders();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function seedUsers(): void
|
protected function seedUsers(): void
|
||||||
@@ -68,4 +68,9 @@ class FillJsonData extends Seeder
|
|||||||
{
|
{
|
||||||
(new Migrators\VisaMasterPaymentOrdersMigrator)->migrate();
|
(new Migrators\VisaMasterPaymentOrdersMigrator)->migrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function seedActionEvents(): void
|
||||||
|
{
|
||||||
|
(new Migrators\ActionEventsMigrator)->migrate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
database/seeders/Migrators/ActionEventsMigrator.php
Normal file
26
database/seeders/Migrators/ActionEventsMigrator.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders\Migrators;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use JsonMachine\Items;
|
||||||
|
|
||||||
|
class ActionEventsMigrator
|
||||||
|
{
|
||||||
|
public function migrate(): void
|
||||||
|
{
|
||||||
|
DB::table('action_events')->truncate();
|
||||||
|
|
||||||
|
$path = database_path('data/tested/action_events.json');
|
||||||
|
|
||||||
|
$items = Items::fromFile($path);
|
||||||
|
|
||||||
|
foreach ($items as $id => $item) {
|
||||||
|
if (! $item) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::table('action_events')->insert((array) $item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,8 +10,6 @@ class LoanOrdersMigrator
|
|||||||
{
|
{
|
||||||
public function migrate(): void
|
public function migrate(): void
|
||||||
{
|
{
|
||||||
// Running on seeder file, may not work.
|
|
||||||
|
|
||||||
DB::table('loan_orders')->truncate();
|
DB::table('loan_orders')->truncate();
|
||||||
|
|
||||||
$path = database_path('data/nurmuhammetsdb/loan_orders.json');
|
$path = database_path('data/nurmuhammetsdb/loan_orders.json');
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Database\Seeders\Migrators\ActionEventsMigrator;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::redirect('/', filament_path());
|
Route::redirect('/', filament_path());
|
||||||
|
|
||||||
Route::get('test', function () {
|
Route::get('test', function () {
|
||||||
|
(new ActionEventsMigrator())->migrate();
|
||||||
|
|
||||||
return 'done';
|
return 'done';
|
||||||
});
|
});
|
||||||
// Route::middleware(['auth'])->group(function () {
|
// Route::middleware(['auth'])->group(function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user