| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace App\Models;
- use DateTimeInterface;
- use Illuminate\Database\Eloquent\Model;
- class BaseModel extends Model
- {
- /**
- * 自动维护时间戳created_at和updated_at
- *
- * @var bool
- */
- public $timestamps = true;
- /**
- * 自增主键
- * @var bool
- */
- public $incrementing = true;
- /**
- * 保护字段.
- * @var string[]
- */
- protected $guarded = ['id'];
- /**
- * 定义分页尺码
- *
- * @var int
- */
- protected $perPage = 20;
- /**
- * 时间序列化修改
- *
- * @param DateTimeInterface $date
- * @return string
- */
- protected function serializeDate(DateTimeInterface $date)
- {
- return $date->format("Y-m-d H:i:s");
- }
- }
|