2024_02_19_132425_create_custom_fields_table.php 922 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. */
  10. public function up(): void
  11. {
  12. Schema::create('custom_fields', function (Blueprint $table) {
  13. $table->id();
  14. $table->string('group', 50);
  15. $table->string('key', 50);
  16. $table->json('label')->nullable();
  17. $table->tinyInteger('type')->default(1)->comment('1: text, 2: textarea, 3: select, 4: number');
  18. $table->json('options')->nullable();
  19. $table->tinyInteger('required')->default(0)->comment('0: no, 1: yes');
  20. $table->unique(['group', 'key']);
  21. });
  22. }
  23. /**
  24. * Reverse the migrations.
  25. */
  26. public function down(): void
  27. {
  28. Schema::dropIfExists('custom_fields');
  29. }
  30. };