Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions app/Models/ReportTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,44 +44,6 @@ protected static function booted()
$builder->where('created_by', auth()->id());
}
});

static::created(function (ReportTemplate $reportTemplate) {
$logAction = new Actionlog([
'item_type' => ReportTemplate::class,
'item_id' => $reportTemplate->id,
'created_by' => auth()->id(),
]);

$logAction->logaction('create');
});

static::updated(function (ReportTemplate $reportTemplate) {
$changed = [];

foreach ($reportTemplate->getDirty() as $key => $value) {
$changed[$key] = [
'old' => $reportTemplate->getOriginal($key),
'new' => $reportTemplate->getAttribute($key),
];
}

$logAction = new Actionlog();
$logAction->item_type = ReportTemplate::class;
$logAction->item_id = $reportTemplate->id;
$logAction->created_by = auth()->id();
$logAction->log_meta = json_encode($changed);
$logAction->logaction('update');
});

static::deleted(function (ReportTemplate $reportTemplate) {
$logAction = new Actionlog([
'item_type' => ReportTemplate::class,
'item_id' => $reportTemplate->id,
'created_by' => auth()->id(),
]);

$logAction->logaction('delete');
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use App\Models\ReportTemplate;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
DB::table("action_logs")
->where("item_type", ReportTemplate::class)
->whereIn("action_type", ["create", "update", "delete"])
->delete();
}

/**
* Reverse the migrations.
*/
public function down(): void
{
// nothing to do here...
}
};

This file was deleted.

This file was deleted.

Loading