support/Model 添加如下代码

    1. <?php
    2. /**
    3. * This file is part of webman.
    4. *
    5. * Licensed under The MIT License
    6. * For full copyright and license information, please see the MIT-LICENSE.txt
    7. * Redistributions of files must retain the above copyright notice.
    8. *
    9. * @author walkor<walkor@workerman.net>
    10. * @copyright walkor<walkor@workerman.net>
    11. * @link http://www.workerman.net/
    12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
    13. */
    14. namespace support;
    15. use DateTimeInterface;
    16. use Illuminate\Database\Eloquent\Model as BaseModel;
    17. class Model extends BaseModel
    18. {
    19. /**
    20. * 为数组 / JSON 序列化准备日期。
    21. *
    22. * @param \DateTimeInterface $date
    23. * @return string
    24. */
    25. protected function serializeDate(DateTimeInterface $date)
    26. {
    27. return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    28. }
    29. }