id(); $table->integer('parent_id')->index()->nullable(); $table->string('name')->index()->nullable(); $table->string('code')->unique()->nullable()->comment('机器编码'); $table->integer('station_type_id')->index(); $table->integer('sequence')->index()->nullable(); $table->timestamps(); }); $stationType= StationType::query()->firstOrCreate(['name'=>'料箱出货口']); $station= Station::query()->firstOrCreate(['code'=>'BIN-OUT01','station_type_id'=>$stationType['id']]); $station['sequence']=1; $station['station_type_id']=$stationType['id']; $station->save(); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('stations'); } }