cfmgrv3 init...2
This commit is contained in:
parent
4e85bceb5b
commit
d8be9d8d6c
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Entities\LoggerEntity;
|
use App\Entities\LoggerEntity;
|
||||||
use CodeIgniter\Model;
|
use CodeIgniter\Model;
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ class LoggerModel extends Model
|
|||||||
protected $returnType = 'array'; //object,array,entity명::class
|
protected $returnType = 'array'; //object,array,entity명::class
|
||||||
protected $useSoftDeletes = false;
|
protected $useSoftDeletes = false;
|
||||||
protected $protectFields = true;
|
protected $protectFields = true;
|
||||||
protected $allowedFields = ['user_uid','title','content','status','created_at'];
|
protected $allowedFields = ['user_uid', 'title', 'content', 'status', 'created_at'];
|
||||||
|
|
||||||
// Dates
|
// Dates
|
||||||
protected $useTimestamps = true;
|
protected $useTimestamps = true;
|
||||||
@ -50,8 +51,10 @@ class LoggerModel extends Model
|
|||||||
|
|
||||||
public function getEntity(int $uid): null|LoggerEntity
|
public function getEntity(int $uid): null|LoggerEntity
|
||||||
{
|
{
|
||||||
$entity = $this->asObject(LoggerEntity::class)->where('uid',$uid)->first();
|
$entity = $this->asObject(LoggerEntity::class)->where('uid', $uid)->first();
|
||||||
if(is_null($entity)){ throw new \Exception(__METHOD__."에서 {$uid} 해당 정보가 없습니다."); }
|
if (is_null($entity)) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 {$uid} 해당 정보가 없습니다.");
|
||||||
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,13 +63,13 @@ class LoggerModel extends Model
|
|||||||
$this->orLike('title', $word, 'both');
|
$this->orLike('title', $word, 'both');
|
||||||
$this->orLike('content', $word, 'both'); //befor , after , both
|
$this->orLike('content', $word, 'both'); //befor , after , both
|
||||||
}
|
}
|
||||||
public function setIndexDateFilter($start,$end)
|
public function setIndexDateFilter($start, $end)
|
||||||
{
|
{
|
||||||
$this->where('created_at >=', $start);
|
$this->where('created_at >=', $start);
|
||||||
$this->where('created_at <=', $end);
|
$this->where('created_at <=', $end);
|
||||||
}
|
}
|
||||||
public function setIndexOrderBy($field, $order = 'ASC')
|
public function setIndexOrderBy($field, $order = 'ASC')
|
||||||
{
|
{
|
||||||
$this->orderBy("title ASC, {$field} {$order}");
|
$this->orderBy("{$field} {$order}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user