Browse Source

修改路径分隔符,使得其只在linux环境运行

Zhouzhendong 4 năm trước cách đây
mục cha
commit
27b696e9e2

+ 2 - 2
app/Http/Controllers/TestController.php

@@ -158,7 +158,7 @@ class TestController extends Controller
     public function test2()
     {
         ini_set('max_execution_time',-1);
-        $myfile = fopen(base_path()."\\database\\data\\menus.data", "a+");
+        $myfile = @fopen(base_path()."/database/data/menus.data", "a+");
         foreach (Menu::query()->get() as $menu){
             $txt = "INSERT INTO menus";
             $columns = "(";
@@ -174,7 +174,7 @@ class TestController extends Controller
         }
         fclose($myfile);
 
-        $myfile = fopen(base_path()."\\database\\data\\authorities.data", "a+");
+        $myfile = @fopen(base_path()."/database/data/authorities.data", "a+");
         foreach (Authority::query()->get() as $authority){
             $txt = "INSERT INTO authorities";
             $columns = "(";

+ 1 - 1
app/Observers/AuthorityObserver.php

@@ -59,7 +59,7 @@ class AuthorityObserver
 
     private function write($txt)
     {
-        $myfile = fopen(base_path()."\\database\\data\\authorities.data", "a+");
+        $myfile = @fopen(base_path()."/database/data/authorities.data", "a+");
         fwrite($myfile, $txt);
         fclose($myfile);
     }

+ 1 - 1
app/Observers/MenuObserver.php

@@ -59,7 +59,7 @@ class MenuObserver
 
     private function write($txt)
     {
-        $myfile = fopen(base_path()."\\database\\data\\menus.data", "a+");
+        $myfile = @fopen(base_path()."/database/data/menus.data", "a+");
         fwrite($myfile, $txt);
         fclose($myfile);
     }