32 lines
776 B
PHP
32 lines
776 B
PHP
<?php
|
|
|
|
namespace App\Traits;
|
|
|
|
use App\Entities\CommonEntity;
|
|
use App\Services\MyLogService;
|
|
|
|
|
|
trait MylogTrait
|
|
{
|
|
final public function add_MylogTrait(string $action, array $formDatas, ?CommonEntity $entity = null): void
|
|
{
|
|
switch ($action) {
|
|
case 'create':
|
|
foreach ($formDatas as $field => $value) {
|
|
MyLogService::add("info", "{$field}:{$value}");
|
|
}
|
|
break;
|
|
case 'modify':
|
|
foreach ($formDatas as $field => $value) {
|
|
MyLogService::add("info", "{$field}:{$entity->$field}=>{$formDatas[$field]}");
|
|
}
|
|
break;
|
|
case 'delete':
|
|
foreach ($this->getModel()->getFields() as $field) {
|
|
MyLogService::add("info", "{$field}:{$entity->$field}");
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|