cfmgrv4/app/Controllers/Admin/UserSNSController.php
2025-03-13 11:25:45 +09:00

65 lines
2.2 KiB
PHP

<?php
namespace App\Controllers\Admin;
use CodeIgniter\HTTP\DownloadResponse;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Helpers\UserSNSHelper;
use App\Models\UserModel;
use App\Services\UserSNSService;
class UserSNSController extends AdminController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->title = lang("{$this->getService()->getClassPath()}.title");
$this->helper = new UserSNSHelper();
}
protected function getService(): UserSNSService
{
if ($this->service === null) {
$this->service = new UserSNSService();
$this->class_name = $this->service->getClassName();
$this->class_path = $this->service->getClassPath();
}
return $this->service;
}
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case $this->getService()->getModel()::PARENT:
$userModel = model(UserModel::class);
// $this->getUserModel()->where('status', DEFAULTS['STATUS']);
$options[$field] = $userModel->getFormFieldOption($field);
// echo $this->getUserModel()->getLastQuery();
// dd($options);
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
//생성
protected function create_init(string $action, $fields = []): void
{
$fields = [
'fields' => [$this->getService()->getModel()::PARENT, 'site', 'id', $this->getService()->getModel()::TITLE, 'email'],
];
parent::create_init($action, fields: $fields);
}
//수정
protected function modify_init(string $action, $fields = []): void
{
$fields = [
'fields' => [$this->getService()->getModel()::PARENT, 'site', 'id', $this->getService()->getModel()::TITLE, 'email', 'status'],
];
parent::modify_init($action, $fields);
}
}