is_system = app()->runningInConsole(); $activity->ip = request()->getClientIp(); //Log::error($activity); //Log::error($entity); 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(); $backup->activity_id = $activity->id; $backup->json_backup = $entity->toJson(); $backup->save(); } }