getPathname()); // If the file doesn't exist in the database, delete it $products = Product::whereJsonContains('images', $relativePath)->get(); if (count($products) < 1) { echo time() . ' Deleting ' . $relativePath . PHP_EOL; File::delete($file); // Delete the file from server } } } }