35 lines
974 B
PHP
35 lines
974 B
PHP
<?php
|
|
|
|
namespace App\Libraries\Mangboard;
|
|
|
|
use App\Entities\Mangboard\UserEntity;
|
|
use App\Models\Mangboard\UserModel;
|
|
|
|
class FreeboardLibrary extends MangboardLibrary
|
|
{
|
|
|
|
private $_model = null;
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
private function getModel(): UserModel
|
|
{
|
|
if ($this->_model === null) {
|
|
$this->_model = new UserModel();
|
|
}
|
|
return $this->_model;
|
|
}
|
|
|
|
public function create($id, int $point, $sign = '+'): UserEntity
|
|
{
|
|
$entity = is_numeric($id) ? $this->getModel()->getEntityByPK(intval($id)) : $this->getModel()->getEntityByID($id);
|
|
if (!$entity) {
|
|
throw new \Exception("해당 회원[{$id}]이 없습니다.");
|
|
}
|
|
$entity = $this->getModel()->setPoint($entity, $point);
|
|
log_message("debug", __FUNCTION__ . "=>[{$entity}] 회원님의 Level은 {$entity->getLevel()} 입니다.");
|
|
return $entity;
|
|
}
|
|
}
|