173 lines
6.4 KiB
PHP
173 lines
6.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Mangboard;
|
|
|
|
use App\Entities\Mangboard\FreeboardEntity;
|
|
use App\Models\CommonModel;
|
|
|
|
class FreeboardModel extends CommonModel
|
|
{
|
|
protected $table = 'mb_board_free;';
|
|
protected $primaryKey = 'pid';
|
|
protected $useAutoIncrement = true;
|
|
protected $returnType = FreeboardEntity::class;
|
|
protected $allowedFields = [
|
|
// 'pid',
|
|
// 'gid',
|
|
'reply',
|
|
'depth',
|
|
'user_id',
|
|
'user_name',
|
|
'title',
|
|
'passwd',
|
|
'homepage',
|
|
'email',
|
|
'address',
|
|
'phone',
|
|
'reg_date',
|
|
'modify_date',
|
|
'calendar_date',
|
|
'hit',
|
|
'user_pid',
|
|
'parent_pid',
|
|
'parent_user_pid',
|
|
'level',
|
|
'file_count',
|
|
'comment_count',
|
|
'vote_good_count',
|
|
'vote_bad_count',
|
|
'vote_type',
|
|
'ip',
|
|
'agent',
|
|
'is_notice',
|
|
'is_secret',
|
|
'status',
|
|
'is_show',
|
|
'reply_email',
|
|
'text',
|
|
'content',
|
|
'content_type',
|
|
'data_type',
|
|
'editor_type',
|
|
'tag',
|
|
'category1',
|
|
'category2',
|
|
'category3',
|
|
'image_path',
|
|
'site_link1',
|
|
'site_link2',
|
|
'gps_latitude',
|
|
'gps_longitude',
|
|
'ext1',
|
|
'ext2',
|
|
'ext3',
|
|
'ext4',
|
|
'ext5',
|
|
'ext6',
|
|
'ext7',
|
|
'ext8',
|
|
'ext9',
|
|
'ext10',
|
|
];
|
|
|
|
// Validation
|
|
// protected $validationRules = [];
|
|
protected $validationRules = [
|
|
'pid' => 'if_exist|trim|numeric',
|
|
'gid' => 'if_exist|trim|numeric',
|
|
'reply' => 'if_exist|trim|numeric',
|
|
'depth' => 'if_exist|trim|numeric',
|
|
'user_id' => 'if_exist|trim|string',
|
|
'user_name' => 'if_exist|trim|string',
|
|
'title' => 'if_exist|trim|string',
|
|
'passwd' => 'if_exist|trim|string',
|
|
'homepage' => 'if_exist|trim|string',
|
|
'email' => 'if_exist|trim|valid_email',
|
|
'address' => 'if_exist|trim|string',
|
|
'phone' => 'if_exist|trim|string',
|
|
// 'reg_date' => 'if_exist|valid_date[Y-m-d hh:ii:dd]',
|
|
// 'modify_date' => 'if_exist|valid_date[Y-m-d hh:ii:dd]',
|
|
// 'calendar_date' => 'if_exist|valid_date[Y-m-d hh:ii:dd]',
|
|
'reg_date' => 'if_exist|string',
|
|
'modify_date' => 'if_exist|string',
|
|
'calendar_date' => 'if_exist|string',
|
|
'hit' => 'if_exist|trim|numeric',
|
|
'user_pid' => 'if_exist|trim|numeric',
|
|
'parent_pid' => 'if_exist|trim|numeric',
|
|
'parent_user_pid' => 'if_exist|trim|numeric',
|
|
'level' => 'if_exist|trim|numeric',
|
|
'file_count' => 'if_exist|trim|numeric',
|
|
'comment_count' => 'if_exist|trim|numeric',
|
|
'vote_good_count' => 'if_exist|trim|numeric',
|
|
'vote_bad_count' => 'if_exist|trim|numeric',
|
|
'vote_type' => 'if_exist|trim|numeric',
|
|
'ip' => 'if_exist|trim|string',
|
|
'agent' => 'if_exist|trim|string',
|
|
'is_notice' => 'if_exist|trim|numeric',
|
|
'is_secret' => 'if_exist|trim|numeric',
|
|
'status' => 'if_exist|trim|string',
|
|
'is_show' => 'if_exist|trim|numeric',
|
|
'reply_email' => 'if_exist|trim|numeric',
|
|
'text' => 'if_exist|string',
|
|
'content' => 'if_exist|string',
|
|
'content_type' => 'if_exist|trim|string',
|
|
'data_type' => 'if_exist|trim|string',
|
|
'editor_type' => 'if_exist|trim|string',
|
|
'tag' => 'if_exist|trim|string',
|
|
'category1' => 'if_exist|trim|string',
|
|
'category2' => 'if_exist|trim|string',
|
|
'category3' => 'if_exist|trim|string',
|
|
'image_path' => 'if_exist|trim|string',
|
|
'site_link1' => 'if_exist|trim|string',
|
|
'site_link2' => 'if_exist|trim|string',
|
|
'gps_latitude' => 'if_exist|trim|string',
|
|
'gps_longitude' => 'if_exist|trim|string',
|
|
'ext1' => 'if_exist|string',
|
|
'ext2' => 'if_exist|string',
|
|
'ext3' => 'if_exist|string',
|
|
'ext4' => 'if_exist|string',
|
|
'ext5' => 'if_exist|string',
|
|
'ext6' => 'if_exist|string',
|
|
'ext7' => 'if_exist|string',
|
|
'ext8' => 'if_exist|string',
|
|
'ext9' => 'if_exist|string',
|
|
'ext10' => 'if_exist|string',
|
|
// 'updated_at' => 'if_exist|valid_date',
|
|
// 'created_at' => 'if_exist|valid_date',
|
|
// 'deleted_at' => 'if_exist|valid_date',
|
|
];
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function getPK(): string
|
|
{
|
|
return $this->primaryKey;
|
|
}
|
|
|
|
public function getEntityByPK(int $uid): null|FreeboardEntity
|
|
{
|
|
$this->where($this->getPK(), $uid);
|
|
return $this->getEntity();
|
|
}
|
|
public function getEntityByID(string $id): null|FreeboardEntity
|
|
{
|
|
$this->where('user_id', $id);
|
|
return $this->getEntity();
|
|
}
|
|
|
|
public function create(FreeboardEntity $entity, array $formDatas = []): FreeboardEntity
|
|
{
|
|
$entity = $this->create_process($entity, $formDatas);
|
|
//GID값이 PK랑 같게하기위해
|
|
$entity->setGID($entity->getPK());
|
|
$entity = $this->modify_process($entity, $formDatas);
|
|
return $entity;
|
|
}
|
|
public function modify(FreeboardEntity $entity, array $formDatas = []): FreeboardEntity
|
|
{
|
|
return $this->modify_process($entity, $formDatas);
|
|
}
|
|
}
|