Fix: Add central users table and correct login redirection
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m38s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m38s
- Copy users and roles migrations to central database context - Redirect central domain root to /admin/login - Fix SuperAdminSeeder to include required role_id
This commit is contained in:
35
database/migrations/2021_03_12_074597_create_roles_table.php
Executable file
35
database/migrations/2021_03_12_074597_create_roles_table.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('description')->nullable();
|
||||
$table->string('permission_type');
|
||||
$table->json('permissions')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('roles');
|
||||
}
|
||||
};
|
||||
38
database/migrations/2021_03_12_074857_create_users_table.php
Normal file
38
database/migrations/2021_03_12_074857_create_users_table.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password')->nullable();
|
||||
$table->boolean('status')->default(0);
|
||||
$table->integer('role_id')->unsigned();
|
||||
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
||||
@@ -17,7 +17,7 @@ class SuperAdminSeeder extends Seeder
|
||||
'name' => 'Super Admin',
|
||||
'password' => Hash::make('admin123'),
|
||||
'status' => 1,
|
||||
// 'role_id' => 1, // Skip role_id if strictly checking email
|
||||
'role_id' => 1,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ Route::middleware([
|
||||
Route::get('/', function () {
|
||||
$centralDomains = config('tenancy.central_domains');
|
||||
if (in_array(request()->getHost(), $centralDomains)) {
|
||||
return redirect()->route('super-admin.tenants.index');
|
||||
return redirect('/admin/login');
|
||||
}
|
||||
return redirect()->route('admin.session.create');
|
||||
});
|
||||
|
||||
@@ -15,8 +15,8 @@ Route::get('/debug-db', function () {
|
||||
});
|
||||
|
||||
Route::get('/', function () {
|
||||
// Redirect central domain to Super Admin
|
||||
return redirect()->route('super-admin.tenants.index');
|
||||
// Redirect central domain to Admin Login
|
||||
return redirect('/admin/login');
|
||||
});
|
||||
|
||||
// Super Admin Routes
|
||||
|
||||
Reference in New Issue
Block a user