Skip to content
This repository was archived by the owner on Apr 19, 2025. It is now read-only.

Commit fb4834f

Browse files
committed
Merge branch 'develop'
2 parents e7812b5 + 60e56bb commit fb4834f

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/config/twofactor-auth.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,24 @@
6464
'post' => '/auth/token',
6565
],
6666

67+
/*
68+
|--------------------------------------------------------------------------
69+
| Database Settings
70+
|--------------------------------------------------------------------------
71+
|
72+
| Starting from Laravel 5.8, the default is to use "bigIncrements" instead
73+
| of "increments" for the "id" column on the "users" table. This setting
74+
| allows you to control what type to use for the "user_id" column on the
75+
| "two_factor_auths" table. The default is to use "unsignedBigInteger" in
76+
| order to stay in line with the changes in Laravel 5.8.
77+
|
78+
| NOTE: Modifying this setting only has an effect before you run any
79+
| migrations for this package. If you need to change the signature of
80+
| "user_id" afterwards, you will have to write your own migration for this
81+
| (see install instructions for more details).
82+
|
83+
*/
84+
85+
'big_int' => true,
86+
6787
];

src/database/migrations/2017_05_26_102832_create_two_factor_auths_table.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Illuminate\Support\Facades\DB;
34
use Illuminate\Support\Facades\Schema;
45
use Illuminate\Database\Schema\Blueprint;
56
use Illuminate\Database\Migrations\Migration;
@@ -15,7 +16,13 @@ public function up()
1516
{
1617
Schema::create('two_factor_auths', function (Blueprint $table) {
1718
$table->string('id')->nullable();
18-
$table->unsignedInteger('user_id');
19+
20+
if ($this->useBigInt()) {
21+
$table->unsignedBigInteger('user_id');
22+
} else {
23+
$table->unsignedInteger('user_id');
24+
}
25+
1926
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
2027
$table->timestamps();
2128
});
@@ -30,4 +37,15 @@ public function down()
3037
{
3138
Schema::dropIfExists('two_factor_auths');
3239
}
40+
41+
/**
42+
* Determine if the type of the "user_id" column should be of type
43+
* "unsignedBigInteger".
44+
*
45+
* @return bool
46+
*/
47+
private function useBigInt()
48+
{
49+
return config('twofactor-auth.big_int');
50+
}
3351
}

0 commit comments

Comments
 (0)