2021_11_15_382711_delete_tencent_table.php 889 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class DeleteTencentTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. $path = base_path('plugins/room/tencentcloud');
  15. $this->delFile($path);
  16. @rmdir($path);
  17. }
  18. /**
  19. * Reverse the migrations.
  20. *
  21. * @return void
  22. */
  23. public function down()
  24. {
  25. //
  26. }
  27. private function delFile($path)
  28. {
  29. if (is_dir($path)) {
  30. $p = scandir($path);
  31. if (count($p) > 2) {
  32. foreach ($p as $val) {
  33. if ($val != "." && $val != "..") {
  34. if (is_dir($path . '/' . $val)) {
  35. $this->delFile($path . '/' . $val . '/');
  36. @rmdir($path . '/' . $val );
  37. } else {
  38. unlink($path . '/' . $val);
  39. }
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }