Automation/app/Models/Mngboard/FreeboardModel.php
2024-09-05 17:22:34 +09:00

51 lines
1.7 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', 'user_id', 'passwd', 'user_name', 'user_email', 'user_state', 'user_level', 'user_point'];
// Validation
// protected $validationRules = [];
protected $validationRules = [
'pid' => 'if_exist|numeric',
'user_id' => 'if_exist|trim|string',
'passwd' => 'if_exist|trim|string',
// 'confirmpassword' => 'if_exist|trim|matches[passwd]',
'user_name' => 'if_exist|trim|string',
'user_state' => 'if_exist|trim|string',
'user_email' => 'if_exist|trim|valid_email',
'user_level' => 'if_exist|numeric',
'user_point' => 'if_exist|numeric',
// 'proxied' => 'if_exist|in_list[on,off]',
// 'fixed' => 'if_exist|in_list[on,off]',
// 'locked' => 'if_exist|in_list[on,off]',
// 'updated_at' => 'if_exist|valid_date',
// 'created_at' => 'if_exist|valid_date',
];
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();
}
}