diff --git a/app/Models/CommonConfig.php b/app/Models/CommonConfig.php index e16557f7d..29c0601f0 100644 --- a/app/Models/CommonConfig.php +++ b/app/Models/CommonConfig.php @@ -25,7 +25,7 @@ class CommonConfig extends Model { - protected $primaryKey = ['name', 'namespace']; + protected $primaryKey = 'id'; public $incrementing = false; protected $fillable = ['name', 'namespace', 'value']; diff --git a/database/migrations/2017_02_28_031017_common_configs.php b/database/migrations/2017_02_28_031017_common_configs.php index 3b206336d..da4e36dd8 100644 --- a/database/migrations/2017_02_28_031017_common_configs.php +++ b/database/migrations/2017_02_28_031017_common_configs.php @@ -30,11 +30,14 @@ class CommonConfigs extends Migration public function up() { Schema::create('common_configs', function (Blueprint $table) { + $table->increments('id')->comment('config id'); $table->string('name', 100)->comment('配置名称'); $table->string('namespace', 100)->comment('配置命名空间'); $table->text('value')->nullable()->comment('缓存值'); $table->timestamps(); - $table->primary(['name', 'namespace']); + $table->unique(['name', 'namespace']); + $table->index('name'); + $table->index('namespace'); }); } diff --git a/database/seeds/CommonConfigSeeder.php b/database/seeds/CommonConfigSeeder.php index 5c0e7ffd7..8bd282f86 100644 --- a/database/seeds/CommonConfigSeeder.php +++ b/database/seeds/CommonConfigSeeder.php @@ -28,10 +28,10 @@ class CommonConfigSeeder extends Seeder */ public function run() { - CommonConfig::create([ - 'name' => 'default_role', - 'namespace' => 'user', - 'value' => 2, - ]); + $configire = new CommonConfig(); + $configire->namespace = 'user'; + $configire->name = 'default_role'; + $configire->value = 2; + $configire->save(); } }