Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dels07's avatar

Laravel cannot use moveDirectory and copyDirectory problem

Currently I having problem with Laravel cannot use moveDirectory and copyDirectory however makeDirectory or deleteDirectory works fine, the code as follow:

<?php

namespace App\Http\Controllers\Backend;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;

use App\Http\Requests;

use App\Property;

use Intervention;

class PropertyController extends Controller {

    public function update(Request $request, $id) {
        $property = Property::findOrFail($id);
        $oldName  = $property->name;

        $property->fill($request->all());
        if ($request->name == '') {
            $property->name = str_slug($request->title);
        }
        $property->updated_by = Auth::user()->username;

        if ($oldName !== $property->name) {
            Storage::disk('public')->moveDirectory('images/'.$oldName, 'images/'.$property->name);
        }
        $property->save();

        show_feedback('info', 'Property successfully updated');

        return redirect(route('property-management.index'));
    }
}

with error:

BadMethodCallException in PluggableTrait.php line 85:
Call to undefined method League\Flysystem\Filesystem::moveDirectory
0 likes
2 replies
bobbybouwmann's avatar

The method does exists... Maybe your filesystem driver does not support it?

dels07's avatar
dels07
OP
Best Answer
Level 1

I playaround and use File::moveDirectory from Illuminate\Support\Facades\File and it works, likely this method is not available using Facades\Storage

1 like

Please or to participate in this conversation.