<?php

namespace lib\Controllers\DBMS\Client;

use lib\Services\MemberService;
use lib\Services\OnetimeService;

class OnetimeController extends ClientController
{
    private ?OnetimeService $_onetimeService = null;
    private ?MemberService $_memberService = null;
    public function __construct()
    {
        parent::__construct();
        $this->getView()->setPath('onetime');
    } //

    public function getOnetimeService(): OnetimeService
    {
        if ($this->_onetimeService === null) {
            $this->_onetimeService = new OnetimeService();
        }
        return $this->_onetimeService;
    }
    public function getMemberService(): MemberService
    {
        if ($this->_memberService === null) {
            $this->_memberService = new MemberService();
        }
        return $this->_memberService;
    }
    //domain_buy_list.php
    //CLI 접속방법 : php index.php site/counpon
    //WEB 접속방법 : http://localhost/site/coupon
    public function coupon()
    {
        //쿠폰내역
        $this->getOnetimeService()->getModel()->like(["onetime_case" => "%domain%"]);
        $this->getOnetimeService()->getModel()->orderBy("onetime_request_date", "DESC");
        $this->entities = $this->getOnetimeService()->getEntities();
        //해당 고객정보
        $this->clients = $this->getClientService()->getEntities();
        //전체 관리자정보(등록자)
        $this->members = $this->getMemberService()->getEntities();
        return $this->render(__FUNCTION__);
    }
} //Class
