52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Entities\MyLogEntity;
|
|
|
|
class MyLogModel extends CommonModel
|
|
{
|
|
const TABLE = "mylog";
|
|
const PK = "uid";
|
|
const TITLE = "title";
|
|
protected $table = self::TABLE;
|
|
protected $primaryKey = self::PK;
|
|
protected $returnType = MyLogEntity::class;
|
|
protected $allowedFields = [
|
|
"uid",
|
|
"user_uid",
|
|
"title",
|
|
"content",
|
|
"status",
|
|
"updated_at",
|
|
];
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
public function getFormRule(string $action, string $field): string
|
|
{
|
|
if (is_array($field)) {
|
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
|
}
|
|
switch ($field) {
|
|
case "user_uid":
|
|
$rule = "required|numeric";
|
|
break;
|
|
case 'titler':
|
|
$rule = "required|trim|string";
|
|
break;
|
|
case 'content':
|
|
$rule = "permit_empty|trim|string";
|
|
break;
|
|
case 'status':
|
|
$rule = "permit_empty|trim|string";
|
|
break;
|
|
default:
|
|
$rule = parent::getFormRule($action, $field);
|
|
break;
|
|
}
|
|
return $rule;
|
|
}
|
|
}
|