<?php
namespace App\Controllers\Interest;

use App\Controllers\BaseController;
use App\Models\common\CodeModel;
use App\Models\interest\RatesModel;

class Rates extends BaseController
{
  private $model, $codeModel;

  public function __construct()
  {
    $this->model = new RatesModel();
    $this->codeModel = new CodeModel();
  }

  public function lists(): string
  {

    $codes = $this->codeModel->getCodeLists(['BANK', 'INSURANCE', 'LOAN_PLACE']); // 코드조회

    $placeArr = [];
    foreach ($codes as $c) {
      if ($c['category'] == "LOAN_PLACE") {
        array_push($placeArr, $c);
      }

    }

    $data = $this->model->getLists();


    $this->data['place'] = $placeArr;
    $this->data['data'] = $data;

    return view("pages/interest/list", $this->data);
  }

}