Skip to content

Commit c5e3b56

Browse files
committed
Init user logins structure + migrations
1 parent 44c556c commit c5e3b56

19 files changed

+366
-20
lines changed

config/users.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,10 @@
77
'model' => \Backstage\LaravelUsers\Eloquent\Models\User::class,
88
'table' => 'users',
99
],
10+
11+
'user_login' => [
12+
'model' => \Backstage\LaravelUsers\Eloquent\Models\UserLogin::class,
13+
'table' => 'user_logins',
14+
],
1015
],
1116
];
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Filament\Pages\SubNavigationPosition;
5+
use Illuminate\Database\Schema\Blueprint;
6+
use Illuminate\Database\Migrations\Migration;
7+
8+
return new class extends Migration
9+
{
10+
/**
11+
* Run the migrations.
12+
*/
13+
public function up(): void
14+
{
15+
Schema::table('users', function (Blueprint $table) {
16+
$table->enum('sub_navigation_preference', ['start', 'end', 'top'])
17+
->default('top')
18+
->after('remember_token')
19+
->comment('The user\'s preference for the sub navigation position. The default is top.');
20+
});
21+
}
22+
23+
/**
24+
* Reverse the migrations.
25+
*/
26+
public function down(): void
27+
{
28+
Schema::table('users', function (Blueprint $table) {
29+
$table->dropColumn('sub_navigation_preference');
30+
});
31+
}
32+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create(config('users.eloquent.user_login.table', 'user_logins'), function (Blueprint $table) {
15+
$table->id();
16+
$table->unsignedBigInteger('user_id')->nullable();
17+
18+
$table->string('type')->nullable();
19+
$table->string('url')->nullable();
20+
$table->string('referrer')->nullable();
21+
$table->text('inputs')->nullable();
22+
$table->string('user_agent')->nullable();
23+
$table->string('ip_address')->nullable();
24+
$table->string('hostname')->nullable();
25+
26+
$table->timestamps();
27+
});
28+
}
29+
30+
/**
31+
* Reverse the migrations.
32+
*/
33+
public function down(): void
34+
{
35+
Schema::dropIfExists(config('users.eloquent.user_login.table', 'user_logins'));
36+
}
37+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('user_traffic', function (Blueprint $table) {
15+
$table->id();
16+
$table->unsignedBigInteger('user_id')->nullable();
17+
$table->string('method', 10);
18+
$table->string('path');
19+
$table->text('full_url');
20+
$table->ipAddress('ip')->nullable();
21+
$table->text('user_agent')->nullable();
22+
$table->text('referer')->nullable();
23+
$table->string('route_name')->nullable();
24+
$table->string('route_action')->nullable();
25+
$table->json('route_parameters')->nullable();
26+
$table->timestamps();
27+
});
28+
}
29+
30+
/**
31+
* Reverse the migrations.
32+
*/
33+
public function down(): void
34+
{
35+
Schema::dropIfExists('user_traffic');
36+
}
37+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration {
8+
public function up(): void
9+
{
10+
Schema::create('users_tags', function (Blueprint $table) {
11+
$table->id();
12+
$table->string('name')->unique();
13+
$table->timestamps();
14+
});
15+
}
16+
17+
public function down(): void
18+
{
19+
Schema::dropIfExists('users_tags');
20+
}
21+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration {
8+
public function up(): void
9+
{
10+
Schema::create('users_tags_pivot', function (Blueprint $table) {
11+
$table->id();
12+
$table->unsignedBigInteger('user_id');
13+
$table->unsignedBigInteger('tag_id');
14+
$table->timestamps();
15+
});
16+
}
17+
18+
public function down(): void
19+
{
20+
Schema::dropIfExists('users_tags_pivot');
21+
}
22+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('users', function (Blueprint $table) {
15+
$table->string('password')->nullable()->change();
16+
});
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
Schema::table('users', function (Blueprint $table) {
25+
$table->string('password')->nullable(false)->change();
26+
});
27+
}
28+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('user_notification_preferences', function (Blueprint $table) {
15+
$table->id();
16+
$table->unsignedBigInteger('user_id');
17+
$table->string('navigation_type');
18+
$table->timestamps();
19+
20+
$table->unique(['user_id', 'navigation_type']);
21+
});
22+
}
23+
24+
/**
25+
* Reverse the migrations.
26+
*/
27+
public function down(): void
28+
{
29+
Schema::dropIfExists('user_notification_preferences');
30+
}
31+
};

database/migrations/create_users_table.php.stub

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
namespace Backstage\LaravelUsers\Eloquent\Concerns\User;
4+
5+
trait HasAttributes {}

0 commit comments

Comments
 (0)