Search code examples
laravellaravel-7laravel-storage

How to edit a folder name in storage folder in laravel


I am creating a folder for my project in "Laravel" and saves all files inside a folder the same-named as the slug of the project. Whenever I edit my title my slug edited too. So I want my slug folder name to be updated with containing my assets inside the folder

Example:

Project Creation:

Title: My first test project Slug: my-first-test-project (auto generated from title)

Directory Name: my-first-test-project (same as slug name)

Project Update:

Title: My updated first project Slug: my-updated-first-project

Directory Name: my-updated-first-project (directory files should remain unchanged)


Solution

  • Try it:

    Storage::moveDirectory(string $from, string $to, bool $overwrite = false)
    

    Documentation: File Storage \ Directories