| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\common\model;
- use think\Collection;
- use think\Model;
- abstract class BaseModel extends Model
- {
- protected $autoWriteTimestamp = true;
- protected $updateTime = 'update_time';
- protected $createTime = 'create_time';
- public function __call($method, $args)
- {
- return parent::__call($method, $args); // TODO: Change the autogenerated stub
- }
- abstract protected function genSchema(array $schema);
- public function getCreateTimeAttr($v) {
- if(!$v)return $v;
- return date("Y-m-d H", $v);
- }
- public function getUpdateTimeAttr($v) {
- if(!$v)return $v;
- return date("Y-m-d H", $v);
- }
- public function deleteByIds(array $ids) {
- return $this->whereIn('id',$ids)->update(['is_delete' => 1]);
- }
- /**
- * @param $id
- * @return BaseModel|array|mixed|Model|null
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function findById($id) {
- return $this->where([
- ['id','=',$id],
- ['is_delete','=', 0]
- ])->find();
- }
- }
|