Raffales-LMS/app/Models/Log/ActivityLog.php

36 lines
707 B
PHP
Raw Permalink Normal View History

2024-04-16 09:58:24 +00:00
<?php
namespace App\Models\Log;
use App\Models\User;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ActivityLog extends Model
{
use HasFactory;
protected $primaryKey = 'activity_id';
public $timestamps = true;
protected $fillable = [
'user_id',
'controllerName',
'methodName',
'actionUrl',
'activity',
'created_at',
'updated_at',
];
protected $appends = ['user_name'];
public function getUserNameAttribute()
{
$user = User::find($this->user_id);
return $user ? $user->name : '';
}
}