what is problem ?
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use IlluminateHttpUploadedFile;
use AppUser;
use AppTeam;
use AppClub;
class TeamController extends Controller
{
public function destroy($id)
{
$team=Team::findOrFail($id);
$team->delete();
Storage::delete($team->logo);
return response()->json(['data' => $team],200);
}
}
4
Answers
Maybe you need to declare a use statement for storage
use IlluminateSupportFacadesStorage;
if ($team->logo != null && file_exists(storage_path(‘app/public/’ . Path $team->logo ))) {
unlink(storage_path(‘app/public/’ . Path $team->logo));
}
Path – enter your logo path
You need to delete the
$team->logo
before you delete the$team
. If you delete$team
first,$team->logo
doesn’t exist any longer.// import the storage facade