<?php
namespace App\Repositories\Member;

use Illuminate\Support\Facades\DB;

final class MemStRingRepository
{
    public function getLegacyPass1(int $memNo, int $set = 0): ?string
    {
        $col = 'str_' . (int)$set; // str_0 / str_1 / str_2

        $row = DB::table('mem_st_ring')
            ->select($col)
            ->where('mem_no', $memNo)
            ->first();

        if (!$row) return null;

        $val = $row->{$col} ?? null;
        $val = is_string($val) ? trim($val) : null;

        return $val !== '' ? $val : null;
    }

    public function getLegacyPass2(int $memNo): ?string
    {
        $val = DB::table('mem_st_ring')
            ->where('mem_no', $memNo)
            ->value('passwd2');

        $val = is_string($val) ? trim($val) : null;
        return $val !== '' ? $val : null;
    }
}
