Dev/v1.2 (#4)
Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local> Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
use Modules\Auth\Entities\User;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('public_profile_token', 64)->nullable()->unique()->after('member_type');
|
||||
});
|
||||
|
||||
User::withTrashed()
|
||||
->whereNull('public_profile_token')
|
||||
->cursor()
|
||||
->each(function (User $user) {
|
||||
$user->forceFill([
|
||||
'public_profile_token' => Str::random(48),
|
||||
])->saveQuietly();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropUnique(['public_profile_token']);
|
||||
$table->dropColumn('public_profile_token');
|
||||
});
|
||||
}
|
||||
};
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\Auth\Entities\User;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->timestamp('public_profile_token_expires_at')->nullable()->after('public_profile_token');
|
||||
});
|
||||
|
||||
$expiryDays = (int) config('user.public_profile_token_ttl_days', 90);
|
||||
|
||||
User::withTrashed()
|
||||
->whereNotNull('public_profile_token')
|
||||
->whereNull('public_profile_token_expires_at')
|
||||
->cursor()
|
||||
->each(function (User $user) use ($expiryDays) {
|
||||
$user->forceFill([
|
||||
'public_profile_token_expires_at' => now()->addDays($expiryDays),
|
||||
])->saveQuietly();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('public_profile_token_expires_at');
|
||||
});
|
||||
}
|
||||
};
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->timestamp('onboarding_completed_at')->nullable()->after('birth_place');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('onboarding_completed_at');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user