Skip to content

Commit

Permalink
Merge pull request #13 from cjmellor/fix/add-more-configs
Browse files Browse the repository at this point in the history
feat: Customise constraints
  • Loading branch information
cjmellor committed Jul 22, 2023
2 parents af25a80 + 660d4ca commit 7b2e78f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/level-up.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'user' => [
'foreign_key' => 'user_id',
'model' => App\Models\User::class,
'users_table' => 'users',
],

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ return new class extends Migration {
{
Schema::create('achievement_user', function (Blueprint $table) {
$table->id();
$table->foreignId(column: 'user_id')->constrained();
$table->foreignId(column: config('level-up.user.foreign_key'))->constrained(config('level-up.user.users_table'));
$table->foreignId(column: 'achievement_id')->constrained();
$table->integer(column: 'progress')->nullable()->index();
$table->timestamps();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ return new class extends Migration {
{
Schema::create('experience_audits', function (Blueprint $table) {
$table->id();
$table->foreignId(config('level-up.user.foreign_key'))->constrained('users');
$table->foreignId(config('level-up.user.foreign_key'))->constrained(config('level-up.user.users_table'));
$table->integer('points')->index();
$table->boolean('levelled_up')->default(false);
$table->integer('level_to')->nullable();
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/create_experiences_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ return new class extends Migration
{
Schema::create(config('level-up.table'), function (Blueprint $table) {
$table->id();
$table->foreignId(config('level-up.user.foreign_key'))->constrained('users');
$table->foreignId(config('level-up.user.foreign_key'))->constrained(config('level-up.user.users_table'));
$table->foreignId('level_id')->constrained();
$table->integer('experience_points')->default(0)->index();
$table->timestamps();
Expand Down

0 comments on commit 7b2e78f

Please sign in to comment.