<?php namespace App\Controllers\Api\Customer\PlansExtra;

use App\Controllers\PrivateController;
use App\Models\PlansExtraModel;
use CodeIgniter\HTTP\ResponseInterface;

class PlansExtraList extends PrivateController
{
  	/**************************************************************************************
     * PUBLIC FUNCTIONS
     **************************************************************************************/

    /**
     * Get plans_extra list
     * @return ResponseInterface
     */
    public function index(): ResponseInterface
    {
        $plansExtra = new PlansExtraModel();
      
        $items = $plansExtra
          	->where("deleted_at", 0)
          	->orderBy("build_count_extra", "ASC")
          	->findAll();

        $list = [];
        foreach ($items as $item) {
            $list[] = [
                "id"    => (int) $item["id"],
                "build_count_extra" => (int) $item["build_count_extra"], // Thêm trường build_count_extra
                "price" => (float) $item["price"],
                "save"  => (float) $item["save"],
            ];
        }

        return $this->respond(["list" => $list], 200);
    }
}