SoftBaseModel.php 640 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. use DateTimeInterface;
  6. class SoftBaseModel extends Model
  7. {
  8. use SoftDeletes;
  9. /**
  10. * 应该被调整为日期的属性
  11. *
  12. * @var array
  13. */
  14. protected $dates = ['deleted_at'];
  15. protected $guarded = [];
  16. /**
  17. * Laravel7 关于日期格式的改动 通过这个方法覆盖
  18. *
  19. * @param DateTimeInterface $date
  20. * @return string
  21. */
  22. protected function serializeDate(DateTimeInterface $date)
  23. {
  24. return $date->format('Y-m-d H:i:s');
  25. }
  26. }