is_system = app()->runningInConsole(); $activity->ip = request()->getClientIp(); foreach ($fields as $key => $value) { $activity->{$key} = $value; } $activity->save(); $this->createBackup($entity, $activity); } /** * Creates a backup. * * @param Collection $entity The entity * @param Collection $activity The activity */ public function createBackup($entity, $activity) { $backup = new Backup(); // if(get_class($entity) == Client::class) // $settings = $entity->getMergedSettings(); // else // $settings = $entity->client->getMergedSettings(); // $entity->clientMergedDettings = $settings; if (get_class($entity) == Client::class) { $entity->load('company'); } elseif (get_class($entity) == User::class) { } else { $entity->load('company', 'client'); } if (get_class($entity) == Invoice::class && ($activity->activity_type_id == Activity::MARK_SENT_INVOICE || $activity->activity_type_id == Activity::PAID_INVOICE)) { //$backup->html_backup = $this->generateInvoiceHtml($entity->design(), $entity); $backup->html_backup = $this->generateEntityHtml($entity->getEntityDesigner(), $entity); } $backup->activity_id = $activity->id; $backup->json_backup = $entity->toJson(); $backup->save(); } }