update root folder by enviroment
This commit is contained in:
		
							parent
							
								
									79b3cbe916
								
							
						
					
					
						commit
						d53b786daf
					
				| 
						 | 
				
			
			@ -125,7 +125,7 @@ class ProfileController extends Controller
 | 
			
		|||
        $rootFolder = rtrim($rootFolder, '/') . '/';
 | 
			
		||||
 | 
			
		||||
        // Get all files and directories in the specified root folder
 | 
			
		||||
        $fileList = $this->getDirectoryTree(public_path($rootFolder), $rootFolder);
 | 
			
		||||
        $fileList = $this->getDirectoryTree(public_path($rootFolder), env('APP_ENV') === 'local' ? $rootFolder: 'image'.$rootFolder);
 | 
			
		||||
 | 
			
		||||
        return response()->json(['data' => $fileList, 'status' => true]);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -219,7 +219,7 @@ class ProfileController extends Controller
 | 
			
		|||
 | 
			
		||||
        // Parse the file path from the URL (remove the base URL part)
 | 
			
		||||
        $storagePath = parse_url($fileUrl, PHP_URL_PATH); // Extract the path part of the URL
 | 
			
		||||
        $filePath = str_replace('/storage/', '', $storagePath); // Remove "/storage/" to get the actual file path
 | 
			
		||||
        $filePath = str_replace(env('APP_ENV') === 'local' ? '/storage/' : '/image/storage/', '', $storagePath); // Remove "/storage/" to get the actual file path
 | 
			
		||||
 | 
			
		||||
        // Check if the file exists before attempting to delete it
 | 
			
		||||
        if (Storage::disk('public')->exists($filePath)) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,7 +55,6 @@ const AllProfiles = () => {
 | 
			
		|||
  const [data, setData] = useState<TFileProfile[]>([])
 | 
			
		||||
  const [currentName, setCurrentName] = useState<string>('')
 | 
			
		||||
  const [openedProfile, setOpenedProfile] = useState(false)
 | 
			
		||||
  const root_folder = import.meta.env.VITE_BACKEND_URL.includes('localhost') ? '/storage/profiles/' : '/image/storage/profiles/'
 | 
			
		||||
  function FileIcon({ name, isFolder, expanded }: FileIconProps) {
 | 
			
		||||
    if (name.endsWith('.pdf')) {
 | 
			
		||||
      return <IconFileTypePdf size={14} />
 | 
			
		||||
| 
						 | 
				
			
			@ -210,7 +209,7 @@ const AllProfiles = () => {
 | 
			
		|||
  const getAllFile = async () => {
 | 
			
		||||
    try {
 | 
			
		||||
      const res = await get(getAllFilesInProfiles, {
 | 
			
		||||
        root_folder: root_folder + currentName,
 | 
			
		||||
        root_folder: '/storage/profiles/' + currentName,
 | 
			
		||||
      })
 | 
			
		||||
      if (res.status === true) {
 | 
			
		||||
        setData(res.data)
 | 
			
		||||
| 
						 | 
				
			
			@ -231,7 +230,7 @@ const AllProfiles = () => {
 | 
			
		|||
  const getTree = async () => {
 | 
			
		||||
    try {
 | 
			
		||||
      const res = await get(getAllFilesInProfiles, {
 | 
			
		||||
        root_folder: root_folder,
 | 
			
		||||
        root_folder: '/storage/profiles',
 | 
			
		||||
      })
 | 
			
		||||
      if (res.status === true) {
 | 
			
		||||
        setTreeData(res.data)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -144,7 +144,6 @@ const Profile = () => {
 | 
			
		|||
  const [otherFiles, setOtherFiles] = useState([{ file: null, type: '' }])
 | 
			
		||||
  const [data, setData] = useState<TFileProfile[]>([])
 | 
			
		||||
  const [openedProfile, setOpenedProfile] = useState(false)
 | 
			
		||||
  const root_folder = import.meta.env.VITE_BACKEND_URL.includes('localhost') ? '/storage/profiles/' : '/image/storage/profiles/'
 | 
			
		||||
  const handleOtherFileChange = (
 | 
			
		||||
    index: number,
 | 
			
		||||
    field: string,
 | 
			
		||||
| 
						 | 
				
			
			@ -210,7 +209,7 @@ const Profile = () => {
 | 
			
		|||
  const getAllFile = async () => {
 | 
			
		||||
    try {
 | 
			
		||||
      const res = await get(getAllFilesInProfiles, {
 | 
			
		||||
        root_folder: root_folder + JSON.parse(getUser())?.user?.name,
 | 
			
		||||
        root_folder: '/storage/profiles/' + JSON.parse(getUser())?.user?.name,
 | 
			
		||||
      })
 | 
			
		||||
      if (res.status === true) {
 | 
			
		||||
        setData(res.data)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue