id(); $table->string('type', 16)->comment('course=课程 activity=活动 custom=自定义'); $table->unsignedBigInteger('course_id')->nullable(); $table->unsignedBigInteger('activity_id')->nullable(); $table->string('title', 255)->nullable()->comment('自定义标题'); $table->string('cover_url', 512)->nullable()->comment('自定义封面图 URL'); $table->longText('content_html')->nullable()->comment('自定义富文本内容'); $table->unsignedInteger('sort')->default(0); $table->unsignedTinyInteger('status')->default(1)->comment('1=启用 0=停用'); $table->timestamps(); $table->softDeletes(); $table->foreign('course_id')->references('id')->on('courses')->nullOnDelete(); $table->foreign('activity_id')->references('id')->on('activities')->nullOnDelete(); $table->index(['type', 'status', 'sort']); }); } public function down(): void { Schema::dropIfExists('banners'); } };