| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- use App\Authority;
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
- class CreateUploadFilesTable extends Migration
- {
- protected $authNames=[
- "运输管理-图片上传",
- "运输管理-图片删除"
- ];
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('upload_files', function (Blueprint $table) {
- $table->string('table_name')->comment('表名');
- $table->string('table_id')->comment('表ID');
- $table->string('url')->unique()->comment('路径');
- $table->string('type')->nullable()->comment('类型');
- $table->timestamps();
- });
- foreach ($this->authNames as $name){
- if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
- }
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('upload_files');
- foreach ($this->authNames as $name){
- Authority::where('name',$name)->delete();
- }
- }
- }
|