visuddhinanda 2 年 前
コミット
3e49aea29d
1 ファイル変更13 行追加0 行削除
  1. 13 0
      app/Tools/Tools.php

+ 13 - 0
app/Tools/Tools.php

@@ -3,6 +3,19 @@ namespace App\Tools;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Log;
 
 
 class Tools{
 class Tools{
+    public static function zip($zipFile,$files){
+        $zip = new \ZipArchive;
+        $res = $zip->open($zipFile, \ZipArchive::CREATE);
+        if ($res === TRUE) {
+            foreach ($files as $key => $value) {
+                $zip->addFromString($key, $value);
+            }
+            $zip->close();
+            return true;
+        } else {
+            return false;
+        }
+    }
     public static function isStop(){
     public static function isStop(){
         if(file_exists(base_path('.stop'))){
         if(file_exists(base_path('.stop'))){
             Log::debug('.stop exists');
             Log::debug('.stop exists');