很好,我有一个原始属性,正在创建一个属性,该属性具有用户通过复选框选择的特征,我想知道如何使用属性 id 保存在特征表中选择的复选框集
控制器
$characteristics = new Characteristic;
$characteristics->characteristic = $request->input('characteristic');
$characteristics->save();
迁移特性
public function up()
{
Schema::create('properties', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->nullable;
$table->string('price')->nullable;
$table->text('description')->nullable;
$table->unsignedBigInteger('property_type_id')->nullable();
$table->unsignedBigInteger('offer_type_id')->nullable();
$table->unsignedBigInteger('spaces_id')->nullable();
$table->unsignedBigInteger('departaments_id')->nullable();
$table->unsignedBigInteger('municipalities_id')->nullable();
$table->unsignedBigInteger('details_id')->nullable();
$table->unsignedBigInteger('characteristics_id')->nullable();
$table->string('images')->nullable;
$table->float('lat')->nullable;
$table->float('lng')->nullable;
$table->string('address')->nullable;
$table->timestamps();
$table->foreign('property_type_id')->references('id')->on('property_type')->onDelete('cascade');
$table->foreign('offer_type_id')->references('id')->on('offer_type')->onDelete('cascade');
$table->foreign('spaces_id')->references('id')->on('spaces')->onDelete('cascade');
$table->foreign('departaments_id')->references('id')->on('departaments')->onDelete('cascade');
$table->foreign('municipalities_id')->references('id')->on('municipalities')->onDelete('cascade');
$table->foreign('details_id')->references('id')->on('details')->onDelete('cascade');
$table->foreign('characteristics_id')->references('id')->on('characteristics')->onDelete('cascade');
});
}
慕丝7291255
千万里不及你