| 12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- use App\Unit;
- use Illuminate\Support\Facades\Schema;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Database\Migrations\Migration;
- class AddUnitJianTuo extends Migration
- {
- protected $names=[
- '件',
- '托',
- ];
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- foreach ($this->names as $name){
- if(!Unit::where('name',$name)->first())(new Unit(['name'=>$name]))->save();
- }
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- foreach ($this->names as $name){
- Unit::where('name',$name)->delete();
- }
- }
- }
|