Skip to content

Commit f027f47

Browse files
committed
We created a replacement for the vordia users table with the existing users table.
1 parent 15c61e4 commit f027f47

File tree

4 files changed

+72
-44
lines changed

4 files changed

+72
-44
lines changed

src/Database/migrations/2025_01_23_151332_create_add_column_mobile_to_table.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/Http/Controllers/Auth/Mobile/MobileOTPController.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ public function requestOTP(MobileRequestOTPRequest $request)
3636
]);
3737
} else {
3838
$user = User::create([
39-
'name' => $request->name ?? 'Null',
40-
'email' => $request->email ?? '[email protected]',
41-
'password' => bcrypt($request->password ?? 'password'),
4239
'mobile' => $mobile,
4340
'otp' => $OTPCode,
4441
'login_token' => $loginToken

src/ServiceProvider/VordiaServiceProvider.php

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Rayiumir\Vordia\ServiceProvider;
44

5+
use Illuminate\Support\Facades\File;
6+
use Illuminate\Support\Facades\Log;
57
use Illuminate\Support\ServiceProvider;
68

79
class VordiaServiceProvider extends ServiceProvider
@@ -14,6 +16,12 @@ class VordiaServiceProvider extends ServiceProvider
1416
public function register(): void
1517
{
1618
$this->mergeConfigFrom(__DIR__ . '/../../config/vordia.php', 'vordia');
19+
20+
if ($this->app->runningInConsole()) {
21+
22+
$this->replaceUsersMigration();
23+
24+
}
1725
}
1826

1927
/**
@@ -25,7 +33,6 @@ public function boot(): void
2533
{
2634
$this->_loadRoutes();
2735
$this->_loadViews();
28-
$this->_loadMigrations();
2936
$this->_loadScripts();
3037
$this->_loadController();
3138
$this->_loadConfig();
@@ -49,16 +56,6 @@ private function _loadRoutes(): void
4956
private function _loadViews(): void
5057
{
5158
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'Vordia');
52-
53-
$this->publishes([__DIR__ . '/../Resources/views' => resource_path('views/')], 'vordia-views');
54-
55-
}
56-
57-
private function _loadMigrations(): void
58-
{
59-
$this->loadMigrationsFrom(__DIR__ . '/../Database/migrations');
60-
61-
$this->publishes([__DIR__ . '/../Database/migrations' => database_path('migrations')], 'vordia-migrations');
6259
}
6360

6461
private function _loadScripts(): void
@@ -83,8 +80,32 @@ private function _loadController(): void
8380

8481
private function _loadConfig(): void
8582
{
86-
$this->publishes([__DIR__ . '/../../config' => config_path('/config'),], 'vordia-config');
83+
$this->publishes([__DIR__ . '/../../config' => config_path('/'),], 'vordia-config');
8784
}
8885

86+
protected function replaceUsersMigration(): void
87+
{
88+
$migrationsPath = database_path('migrations');
89+
$files = File::glob($migrationsPath . '/*_users_table.php');
90+
91+
if (!empty($files)) {
92+
File::put($files[0], File::get(__DIR__.'/../Stubs/create_users_table.php.stub'));
93+
$this->info('Default users migration has been replaced with nullable version.');
94+
} else {
95+
$this->publishes([
96+
__DIR__.'/../Stubs/create_users_table.php.stub' => $this->getMigrationFilename('create_users_table.php'),
97+
], 'migrations');
98+
}
99+
}
100+
101+
protected function getMigrationFilename($migrationName): string
102+
{
103+
return database_path('migrations') . '/' . date('Y_m_d_His') . '_' . $migrationName;
104+
}
105+
106+
protected function info($message): void
107+
{
108+
Log::info($message);
109+
}
89110
}
90111

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('users', function (Blueprint $table) {
17+
$table->id();
18+
$table->string('name')->nullable();
19+
$table->string('email')->nullable();
20+
$table->string('mobile')->unique()->nullable();
21+
$table->string('otp')->nullable();
22+
$table->string('login_token')->nullable();
23+
$table->timestamp('email_verified_at')->nullable();
24+
$table->string('password')->nullable();
25+
$table->rememberToken();
26+
$table->timestamps();
27+
});
28+
}
29+
30+
/**
31+
* Reverse the migrations.
32+
*
33+
* @return void
34+
*/
35+
public function down()
36+
{
37+
Schema::dropIfExists('users');
38+
}
39+
};

0 commit comments

Comments
 (0)