<?php

namespace plugin\admin\app\controller;

use support\Request;
use support\Response;
use support\think\Db;

/**
 * 产品管理
 *
 * @icon fa fa-circle-o
 */
class ProductController extends Crud
{

    /**
     * Product模型对象
     * @var \app\model\Product
     */
    protected $model = null;
    protected $type = 'default'; 
    protected $noNeedAuth = [];

    function __construct()
    {
        $this->model = new \app\model\Product;
        $statusList = $this->model->getStatusList();
        $this->assign("statusList", $statusList);
        $this->assignconfig("statusList", $statusList);
        $cycleTypeList = $this->model->getCycleTypeList();
        $this->assign("cycleTypeList", $cycleTypeList);
        $this->assignconfig("cycleTypeList", $cycleTypeList);
        $this->assign("CategoryOptions", $this->model->getCategoryOptions($this->type));
    }
    public function insert(Request $request): Response
    {
        if ($request->method() != 'POST') {
            return view('update',[
                'row'   =>  [
                    'price'        =>  '10',
                    'interest_rate'        =>  '10',
                    'cycle_type'        =>  'day',
                    'duration_cycle'        =>  1,
                    'billing_cycle'        =>  1,
                    'max_quantity'      =>  0,
                    'interest_type'     =>  30,
                    'status'            =>  1
                ]
            ]);
        }
        return parent::insert($request);
    }
}
