public function delete($model, $log, $fileAttrName = 'files', $fileLogId = 0)
    {
        $updatedFiles = [];
        if ($log)
            $fileLogId = $log->id;

        $fileToDelete = [];
        foreach ($model->files as $file) {
            if ($file['file_log_id'] == $fileLogId)
                $fileToDelete = $file;
            else
                $updatedFiles[] = $file;
        }

        if ($log)
            Storage::delete($log->file_path);
        else
            Storage::delete($fileToDelete['path']);

        if ($log)
            $log->delete();

        $model->$fileAttrName = $updatedFiles;
        return $model;
    }