Skip to content

Commit

Permalink
Added staff action log
Browse files Browse the repository at this point in the history
  • Loading branch information
ipkpjersi committed Oct 26, 2024
1 parent fec73f7 commit 4814faf
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/Models/StaffActionLog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class StaffActionLog extends Model
{
protected $table = 'staff_action_log';

use HasFactory;

protected $fillable = ['user_id', 'target_id', 'action', 'message'];
}
34 changes: 34 additions & 0 deletions database/migrations/2023_08_15_231718_create_staff_action_log.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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('staff_action_log', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id'); // ID of the user who is performing the action
$table->unsignedBigInteger('target_id'); // ID of the user being acted upon
$table->string('action'); // e.g., 'ban', 'remove_avatar'
$table->string('message')->nullable(); // e.g., 'removed avatar 456845967.png for user username (ID: 398)'
$table->timestamps();

$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('target_id')->references('id')->on('users')->onDelete('cascade');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('staff_action_log');
}
};

0 comments on commit 4814faf

Please sign in to comment.