<?php

namespace app\admin\controller\marketing;

use app\admin\validate\marketing\PremisesValidate;
use app\controller\Curd;
use app\model\Premises;
use support\Request;
use support\Response;

class PremisesController extends Curd
{
    public function __construct()
    {
        $this->model = new Premises();
        $this->validate = true;
        $this->validateClass = new PremisesValidate();
    }

    public function select(Request $request): Response
    {
        [$where, $format, $limit, $field, $order] = $this->selectInput($request);
        $order = $request->get('order', 'desc');
        $field = $field ?? 'premises_addtimes';
        $query = $this->doSelect($where, $field, $order);
        return $this->doFormat($query, $format, $limit);
    }
}