argument("path")); $service = new DirService(); $list = $service->recursiveScan($path); if (isset($list["files"]) && count($list["files"]) > 0) { foreach ($list["files"] as $file) { if (strstr($file, ".DS_Store")) { continue; } $fileInfo = pathinfo($file); try { $innerPath = str_replace($path, "", $fileInfo["dirname"]); $innerName = $fileInfo["basename"]; ImageRecord::firstOrCreate(["path" => $innerPath, "name" => $innerName], ["path" => $innerPath, "name" => $innerName, "type" => 2 ] ); } catch (QueryException $e) { if (!str_contains($e->getMessage(), "Duplicate entry")) { Log::error($e->getMessage()); } } unset($imageRecord); } } foreach ($list["dirs"] as $dir) { if (strstr($dir, ".DS_Store") || $dir == ".." || $dir == "." || str_starts_with($dir, ".")) { continue; } try { ImageRecord::firstOrCreate(["path" => $path, "name" => $dir], ["path" => $path, "name" => $dir, "type" => 1 ] ); } catch (QueryException $e) { if (!str_contains($e->getMessage(), "Duplicate entry")) { Log::error($e->getMessage()); } } } } }