2020_09_07_090635_create_admin_settings_table.php 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateAdminSettingsTable extends Migration
  6. {
  7. public function getConnection()
  8. {
  9. return $this->config('database.connection') ?: config('database.default');
  10. }
  11. public function config($key)
  12. {
  13. return config('admin.' . $key);
  14. }
  15. /**
  16. * Run the migrations.
  17. *
  18. * @return void
  19. */
  20. public function up()
  21. {
  22. Schema::create($this->config('database.settings_table') ?: 'admin_settings', function (Blueprint $table) {
  23. $table->string('slug', 100)->primary();
  24. $table->longText('value');
  25. $table->timestamps();
  26. });
  27. }
  28. /**
  29. * Reverse the migrations.
  30. *
  31. * @return void
  32. */
  33. public function down()
  34. {
  35. Schema::dropIfExists($this->config('database.settings_table') ?: 'admin_settings');
  36. }
  37. }