Automation/app/Controllers/Admin/UserController.php
2024-09-02 21:37:17 +09:00

46 lines
1.2 KiB
PHP

<?php
namespace App\Controllers\Admin;
use App\Models\UserModel;
use App\Traits\MangboardTrait;
class UserController extends AdminController
{
use MangboardTrait;
private $_model = null;
public function __construct()
{
$this->_model = new UserModel();
}
public function index()
{
return __METHOD__;
}
public function point()
{
try {
$id = $this->request->getPost('id');
$entity = is_numeric($id) ? $this->_model->getEntityByPK(intval($id)) : $this->_model->getEntityByID($id);
if (!$entity) {
throw new \Exception("해당 회원[{$id}]이 없습니다.");
}
$point = $this->request->getPost('point');
if (!is_numeric($point)) {
throw new \Exception("포인트 값에 {$point}를 사용할 수 없습니다.");
}
$sign = $this->request->getPost('point') ?: "+";
$entity = $this->setUserPointByMangboardTrait($entity, intval($point), $sign);
return "완료되었습니다.";
} catch (\Exception $e) {
log_message("error", $e->getMessage());
return $e->getMessage();
}
}
}