44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin;
|
|
|
|
use App\Models\OrderModel;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class OrderController extends AdminController
|
|
{
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
$this->_model = new OrderModel($this->getFields());
|
|
parent::initController($request, $response, $logger);
|
|
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
|
|
$this->_viewPath .= strtolower($this->_model->getClassName());
|
|
helper($this->_model->getClassName());
|
|
}
|
|
|
|
final public function getFields(string $action = ""): array
|
|
{
|
|
$fields = ["user_uid", 'product_uid', "quantity", "price", "status"];
|
|
switch ($action) {
|
|
case "index":
|
|
case "excel":
|
|
case "view":
|
|
return ["user_uid", 'product_uid', "name", "quantity", "price", "status", "updated_at", "created_at"];
|
|
break;
|
|
default:
|
|
return $fields;
|
|
break;
|
|
}
|
|
}
|
|
final public function getFieldFilters(): array
|
|
{
|
|
return ["user_uid", 'product_uid', "status"];
|
|
}
|
|
final public function getFieldBatchFilters(): array
|
|
{
|
|
return ["status"];
|
|
}
|
|
}
|