diff --git a/app/Helpers/ResponseFormatter.php b/app/Helpers/ResponseFormatter.php new file mode 100644 index 0000000..27f7e48 --- /dev/null +++ b/app/Helpers/ResponseFormatter.php @@ -0,0 +1,33 @@ + [ + 'code' => 200, + 'status' => 'success', + 'message' => null + ], + 'data' => null + ]; + + public static function success($data = null, $message = null) + { + self::$response['meta']['message'] = $message; + self::$response['data'] = $data; + + return response()->json(self::$response, self::$response['meta']['code']); + } + + public static function error($data = null, $message = null, $code = 400) + { + self::$response['meta']['status'] = 'error'; + self::$response['meta']['code'] = $code; + self::$response['meta']['message'] = $message; + self::$response['data'] = $data; + + return response()->json(self::$response, self::$response['meta']['code']); + } +} 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 444fafb..4158dae 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -13,7 +13,7 @@ public function up(): void { Schema::create('users', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->string('nama_lengkap'); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); diff --git a/database/migrations/2025_02_10_144259_add_field_to_users_table.php b/database/migrations/2025_02_10_144259_add_field_to_users_table.php new file mode 100644 index 0000000..b7b3652 --- /dev/null +++ b/database/migrations/2025_02_10_144259_add_field_to_users_table.php @@ -0,0 +1,36 @@ +string('alamat')->after('nama_lengkap'); + $table->date('tgl_lahir')->nullable()->after('alamat'); + $table->string('nama_wali')->nullable()->after('tgl_lahir'); + $table->string('no_telp_wali')->after('nama_wali'); + $table->enum('peran', ['santri', 'pengajar'])->after('no_telp_wali'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('alamat'); + $table->dropColumn('tgl_lahir'); + $table->dropColumn('nama_wali'); + $table->dropColumn('no_telp_wali'); + $table->dropColumn('peran'); + }); + } +};