1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Repositories/ActivityRepository.php
2019-04-21 22:24:26 +10:00

37 lines
664 B
PHP

<?php
namespace App\Repositories;
use App\Models\Activity;
use App\Models\Backup;
class ActivityRepository extends BaseRepository
{
public function save($fields, $entity)
{
$activity = new Activity();
$activity->is_system = app()->runningInConsole();
$activity->ip = request()->getClientIp();
foreach($fields as $key => $value) {
$activity->{$key} = $value;
}
$activity->save();
$this->createBackup($entity, $activity);
}
public function createBackup($entity, $activity)
{
$backup = new Backup();
$backup->activity_id = $activity->id;
$backup->json_backup = $entity->toJson();
$backup->save();
}
}