Laravel 5.4 Storage::delete() not working (method delete not found)

laravel, laravel-5, php

Solution

OK so it turns out that the $filepath needs to be relative to the storage root of the app, not the full file path to the file!

I used a function to update my file path to;

`images/34/o8Aq1T3Hi67sOtuTgBh9P7QWA1Ahj4KH2QBR77n0.png` and it works a charm.

Problem

I am having an issue getting `Storage::delete($filepath);` to work in Laravel 5.4. I have searched for other people with this issue, but the error most others seem to have is providing the file path without the preceding `/`, however this is not my issue. I am using `use Illuminate\Support\Facades\Storage;` (as per the Laravel Docs) and I have noticed I am getting an error in PHPStorm saying `Method delete not found in Illuminate\Support\Facades\Storage`. My code looks like; ``` <?php namespace App\Http\Controllers; ... use Illuminate\Support\Facades\Storage; // also tried use Storage; ... public function deleteFile($id) { try { $image = Files::where('id', $id)->get()->first(); Storage::delete($image->filepath); return Files::destroy($id); } catch ( \Exception $e) { return back()->with('alert-warning', 'Something went wrong: ' . $e); } } ``` My $image->filepath looks like `/Users/usrname/sites/sitename/storage/app/images/34/o8Aq1T3Hi67sOtuTgBh9P7QWA1Ahj4KH2QBR77n0.png` Anyone able to help?

Original source