41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Backend;
|
|
|
|
use App\Models\CategoryModel;
|
|
use App\Models\ProductModel;
|
|
|
|
class ProductBackend extends BaseBackend
|
|
{
|
|
private $_categoryModel = null;
|
|
private $_category_uids = null;
|
|
public function __construct()
|
|
{
|
|
parent::__construct('Product');
|
|
$this->_model = new ProductModel();
|
|
}
|
|
|
|
//Category모델
|
|
final protected function getCategoryModel(): CategoryModel
|
|
{
|
|
return is_null($this->_categoryModel) ? new CategoryModel() : $this->_categoryModel;
|
|
}
|
|
|
|
//Field별 Form Option용
|
|
public function getFieldFormOption(string $field): array
|
|
{
|
|
switch ($field) {
|
|
case 'category_uid':
|
|
$options = $this->_category_uids = $this->_category_uids ?: $this->getCategoryModel()->getFieldFormOptions(['status' => 'use']);
|
|
break;
|
|
default:
|
|
return parent::getFieldFormOption($field);
|
|
break;
|
|
}
|
|
if (!is_array($options)) {
|
|
throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
|
|
}
|
|
return $options;
|
|
}
|
|
}
|