0

I am new to laravel and having trouble figuring out the path and creating a sub folder for workorders when the user submits the order in laravel 11. I have a create user folder on registration in storage-> private-> user_files

This is in my registered userController to create folder. Private2 is my config/filesystems.php file

         $folderName =  $user->id . '_' . $user->name;
       
         $file_folder_path = $folderName;
         $userDirectory = $file_folder_path;
         Storage::disk('private2')->makeDirectory($userDirectory );
    
         $user->save();

Here is a diagram 1.) New user folder created on registration (works)2.) ->orders folder created on order submit form(sub folder for user folder) for new orders(trying to figure out how to reference the user folder that is created with $user->id . '_' . $user->name;)

Thanks

Tried creating new driver in filesystem. Tried adding {user_id}_{user_name} to 'root' => storage_path('app/private/user_files'),

2
  • 1
    So, what issue are you currently facing? Does your code not work? Does it throw an error? What is the expected outcome? Could you elaborate? Commented Oct 22, 2024 at 3:35
  • First thing I see is that 2 of the 3 variables you create are unnecessary, $file_folder_path and $userDirectory hold the exact same value as $folderName and are redundant. Other than that I think $folderName needs a slash before it, so the directory is actually created in your private2 disk. Commented Oct 22, 2024 at 6:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.