Commit ef7860c0 authored by Administrator's avatar Administrator

Update 2 files via Son of Anton

parent 3be93f73
...@@ -12,6 +12,7 @@ abstract class Model ...@@ -12,6 +12,7 @@ abstract class Model
protected static bool $softDelete = true; protected static bool $softDelete = true;
protected static bool $dispatchEvents = true; protected static bool $dispatchEvents = true;
protected static bool $auditEnabled = true; protected static bool $auditEnabled = true;
protected static bool $autoTrackAuthor = true;
protected array $attributes = []; protected array $attributes = [];
protected bool $exists = false; protected bool $exists = false;
...@@ -65,10 +66,12 @@ abstract class Model ...@@ -65,10 +66,12 @@ abstract class Model
$filtered['updated_at'] = date('Y-m-d H:i:s'); $filtered['updated_at'] = date('Y-m-d H:i:s');
} }
if (static::$autoTrackAuthor) {
$employee = App::getInstance()->currentEmployee(); $employee = App::getInstance()->currentEmployee();
if ($employee) { if ($employee) {
$filtered['created_by'] = $employee->id ?? ($employee['id'] ?? null); $filtered['created_by'] = $employee->id ?? ($employee['id'] ?? null);
} }
}
$db = App::getInstance()->db(); $db = App::getInstance()->db();
$id = $db->insert(static::$table, $filtered); $id = $db->insert(static::$table, $filtered);
...@@ -110,10 +113,12 @@ abstract class Model ...@@ -110,10 +113,12 @@ abstract class Model
$filtered['updated_at'] = date('Y-m-d H:i:s'); $filtered['updated_at'] = date('Y-m-d H:i:s');
} }
if (static::$autoTrackAuthor) {
$employee = App::getInstance()->currentEmployee(); $employee = App::getInstance()->currentEmployee();
if ($employee) { if ($employee) {
$filtered['updated_by'] = $employee->id ?? ($employee['id'] ?? null); $filtered['updated_by'] = $employee->id ?? ($employee['id'] ?? null);
} }
}
$db = App::getInstance()->db(); $db = App::getInstance()->db();
$db->update(static::$table, $filtered, '`' . static::$primaryKey . '` = ?', [$this->id]); $db->update(static::$table, $filtered, '`' . static::$primaryKey . '` = ?', [$this->id]);
......
...@@ -14,6 +14,7 @@ class Document extends Model ...@@ -14,6 +14,7 @@ class Document extends Model
protected static bool $timestamps = true; protected static bool $timestamps = true;
protected static bool $softDelete = true; protected static bool $softDelete = true;
protected static bool $dispatchEvents = true; protected static bool $dispatchEvents = true;
protected static bool $autoTrackAuthor = false;
protected static array $fillable = [ protected static array $fillable = [
'member_id', 'document_type', 'original_filename', 'stored_filename', 'member_id', 'document_type', 'original_filename', 'stored_filename',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment