cfmgrv3 init...2

This commit is contained in:
최준흠 2023-06-19 19:28:57 +09:00
parent 2a7de29bf3
commit 723df776c6

View File

@ -1,6 +1,7 @@
<?php
namespace App\Models;
use App\Entities\MapurlEntity;
use CodeIgniter\Model;
@ -14,7 +15,7 @@ class MapurlModel extends Model
protected $returnType = 'array'; //object,array,entity명::class
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['oldurl','newurl','status','updated_at','created_at'];
protected $allowedFields = ['oldurl', 'newurl', 'status', 'updated_at', 'created_at'];
// Dates
protected $useTimestamps = true;
@ -49,8 +50,10 @@ class MapurlModel extends Model
public function getEntity(int $uid): null|MapurlEntity
{
$entity = $this->asObject(MapurlEntity::class)->where('uid',$uid)->first();
if(is_null($entity)){ throw new \Exception(__METHOD__."에서 {$uid} 해당 정보가 없습니다."); }
$entity = $this->asObject(MapurlEntity::class)->where('uid', $uid)->first();
if (is_null($entity)) {
throw new \Exception(__METHOD__ . "에서 {$uid} 해당 정보가 없습니다.");
}
return $entity;
}
@ -59,13 +62,13 @@ class MapurlModel extends Model
$this->orLike('oldurl', $word, 'both'); //befor , after , both
$this->orLike('newurl', $word, 'both'); //befor , after , both
}
public function setIndexDateFilter($start,$end)
public function setIndexDateFilter($start, $end)
{
$this->where('created_at >=', $start);
$this->where('created_at <=', $end);
}
public function setIndexOrderBy($field, $order = 'ASC')
{
$this->orderBy("oldurl ASC, {$field} {$order}");
$this->orderBy("newurl ASC, {$field} {$order}");
}
}