海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
631 B

  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class BaseModel extends Model
  5. {
  6. protected $dateFormat = 'U';
  7. protected $host = '';
  8. public function __construct(array $attributes = [])
  9. {
  10. parent::__construct($attributes);
  11. $this->host = env('APP_URL');
  12. }
  13. # 不转换时间戳,若使用getUpdatedAtColumn,则不能自动写入时间戳
  14. public function getUpdatedAtAttribute($value)
  15. {
  16. return strtotime($value);
  17. }
  18. # 不转换时间戳,若使用getUpdatedAtColumn,则不能自动写入时间戳
  19. public function getCreatedAtAttribute($value)
  20. {
  21. return strtotime($value);
  22. }
  23. }