diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 6c2b6d5..65a8e7f 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -10,14 +10,36 @@ */ public function up(): void { + if (Schema::hasTable('users')) { + throw new \ErrorException('`users` table already exists. please remove migration file and backup user data.'); + } + Schema::create('users', function (Blueprint $table) { $table->id(); + $table->foreignId('parent_id')->nullable()->constrained('users'); $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); + $table->string('mobile')->nullable(); + $table->string('email')->nullable(); + $table->string('login_id')->unique(); $table->string('password'); + $table->unsignedSmallInteger('wrong_password')->default(0); + $table->string('pin')->nullable(); + $table->unsignedSmallInteger('wrong_pin')->default(0); + $table->string('status')->nullable(); + $table->string('language')->nullable(); + $table->string('currency')->nullable(); + $table->string('app_version')->default('1.0.0')->nullable(); $table->rememberToken(); + $table->string('fcm_token')->nullable(); + $table->foreignId('creator_id')->nullable(); + $table->foreignId('editor_id')->nullable(); + $table->foreignId('destroyer_id')->nullable(); + $table->foreignId('restorer_id')->nullable(); $table->timestamps(); + $table->softDeletes(); + $table->timestamp('restored_at')->nullable(); + $table->timestamp('email_verified_at')->nullable(); + $table->timestamp('mobile_verified_at')->nullable(); }); } diff --git a/database/migrations/2023_09_25_201621_update_add_columns_in_users_table.php b/database/migrations/2023_09_25_201621_update_add_columns_in_users_table.php deleted file mode 100644 index 7ba77c0..0000000 --- a/database/migrations/2023_09_25_201621_update_add_columns_in_users_table.php +++ /dev/null @@ -1,70 +0,0 @@ -foreignId('parent_id')->nullable()->default(null)->after('id'); - $table->string('mobile')->nullable()->after('name'); - $table->string('login_id')->unique()->after('email'); - $table->unsignedSmallInteger('wrong_password')->default(0)->after('password'); - $table->string('pin')->after('wrong_password'); - $table->unsignedSmallInteger('wrong_pin')->default(0)->after('pin'); - $table->string('status')->nullable()->after('wrong_pin'); - $table->string('language')->nullable()->after('status'); - $table->string('currency')->nullable()->after('language'); - $table->string('app_version')->default('1'); - $table->string('fcm_token')->nullable()->after('remember_token'); - $table->timestamp('mobile_verified_at')->nullable()->after('email_verified_at'); - $table->foreignId('creator_id')->nullable()->after('mobile_verified_at'); - $table->foreignId('editor_id')->nullable()->after('creator_id'); - $table->foreignId('destroyer_id')->nullable()->after('editor_id'); - $table->foreignId('restorer_id')->nullable()->after('destroyer_id'); - $table->softDeletes()->after('updated_at'); - $table->timestamp('restored_at')->nullable()->after('deleted_at'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - if (Schema::hasTable('users')) { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('parent_id'); - $table->dropColumn('mobile'); - $table->dropColumn('login_id'); - $table->dropColumn('wrong_password'); - $table->dropColumn('pin'); - $table->dropColumn('wrong_pin'); - $table->dropColumn('status'); - $table->dropColumn('language'); - $table->dropColumn('currency'); - $table->dropColumn('app_version'); - $table->dropColumn('fcm_token'); - $table->dropColumn('mobile_verified_at'); - $table->dropColumn('creator_id'); - $table->dropColumn('editor_id'); - $table->dropColumn('destroyer_id'); - $table->dropColumn('restorer_id'); - $table->dropColumn('deleted_at'); - $table->dropColumn('restored_at'); - }); - } - } -}; diff --git a/database/migrations/2023_09_25_201631_create_user_profiles_table.php b/database/migrations/2023_09_25_201631_create_profiles_table.php similarity index 100% rename from database/migrations/2023_09_25_201631_create_user_profiles_table.php rename to database/migrations/2023_09_25_201631_create_profiles_table.php diff --git a/src/Http/Requests/ImportProfileRequest.php b/src/Http/Requests/ImportProfileRequest.php deleted file mode 100644 index 66384bc..0000000 --- a/src/Http/Requests/ImportProfileRequest.php +++ /dev/null @@ -1,52 +0,0 @@ - - */ - public function rules(): array - { - return [ - // - ]; - } - - /** - * Get the validation attributes that apply to the request. - * - * @return array - */ - public function attributes() - { - return [ - // - ]; - } - - /** - * Get the validation messages that apply to the request. - * - * @return array - */ - public function messages() - { - return [ - // - ]; - } -} diff --git a/src/Http/Resources/ProfileResource.php b/src/Http/Resources/ProfileResource.php new file mode 100644 index 0000000..6084e5b --- /dev/null +++ b/src/Http/Resources/ProfileResource.php @@ -0,0 +1,77 @@ +resource->load([ + 'country', 'state', 'city', + 'presentCountry', 'presentState', 'presentCity', + ]); + + return [ + 'user_profile_data' => $this->user_profile_data ?? null, + 'id_type' => $this->id_type ?? null, + 'id_no' => $this->id_no ?? null, + 'id_issue_country' => $this->id_issue_country ?? null, + 'id_expired_at' => $this->id_expired_at ?? null, + 'id_issue_at' => $this->id_issue_at ?? null, + 'id_no_duplicate' => $this->id_no_duplicate ?? null, + 'date_of_birth' => $this->date_of_birth ?? null, + 'address' => $this->permanent_address ?? null, + 'city_id' => $this->city_id ?? null, + 'city_name' => $this->city->name ?? null, + 'state_id' => $this->state_id ?? null, + 'state_name' => $this->state->name ?? null, + 'country_id' => $this->country_id ?? null, + 'country_name' => $this->country->name ?? null, + 'post_code' => $this->post_code ?? null, + 'present_address' => $this->present_address ?? null, + 'present_city_id' => $this->present_city_id ?? null, + 'present_city_name' => $this->presentCity->name ?? null, + 'present_state_id' => $this->present_state_id ?? null, + 'present_state_name' => $this->presentState->name ?? null, + 'present_country_id' => $this->present_country_id ?? null, + 'present_country_name' => $this->presentCountry->name ?? null, + 'present_post_code' => $this->present_post_code ?? null, + 'blacklisted' => $this->blacklisted ?? null, + 'created_at' => $this->created_at ?? null, + 'updated_at' => $this->updated_at ?? null, + ]; + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 3522d63..cc6b570 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -32,7 +32,8 @@ public function getEnvironmentSetUp($app) $migrations = [ include __DIR__ . '/../database/migrations/2014_10_12_000000_create_users_table.php', - include __DIR__ . '/../database/migrations/2023_09_25_201631_create_user_profiles_table.php', + include __DIR__ . '/../database/migrations/2023_09_25_201621_update_add_columns_in_users_table.php', + include __DIR__ . '/../database/migrations/2023_09_25_201631_create_profiles_table.php', include __DIR__ . '/../database/migrations/2023_09_28_224955_create_permission_tables.php', include __DIR__ . '/../database/migrations/2023_09_28_230630_create_teams_table.php' ];