<?php

namespace App\Cells\Customer;

use App\Services\PaymentService;

class PaymentCell extends CustomerCell
{

  public function __construct()
  {
    parent::__construct(new PaymentService());
  }

  public function detail(array $params): string
  {
    $this->getService()->setAction(__FUNCTION__);
    $this->getService()->setFormFields();
    $this->getService()->setFormFilters();
    $this->getService()->setFormRules();
    $this->getService()->setFormOptions();
    $entities = $this->getService()->getEntities(['clientinfo_uid' => $params['clientinfo_uid'], 'billing' => PAYMENT['BILLING']['ONETIME'], 'status' => STATUS['UNPAID']]);
    $template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__;
    return view('cells/payment/' . $template, [
      'serviceCellDatas' => [
        'control' => $this->getService()->getControlDatas(),
        'service' => $this->getService(),
        'entities' => $entities,
      ]
    ]);
  }
}
