Skip to content

Commit

Permalink
fix(Core): 修复公用配置表结构无法与 Laravel 5.7 Model 兼容问题
Browse files Browse the repository at this point in the history
  • Loading branch information
medz committed Nov 9, 2018
1 parent 4e76b65 commit 7cc5ae9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/Models/CommonConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

class CommonConfig extends Model
{
protected $primaryKey = ['name', 'namespace'];
protected $primaryKey = 'id';
public $incrementing = false;
protected $fillable = ['name', 'namespace', 'value'];

Expand Down
5 changes: 4 additions & 1 deletion database/migrations/2017_02_28_031017_common_configs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
}

Expand Down
10 changes: 5 additions & 5 deletions database/seeds/CommonConfigSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 7cc5ae9

Please sign in to comment.