海南旅游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.

27 lines
580 B

  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\Builder;
  5. use Illuminate\Database\Eloquent\Model;
  6. class BaseModel extends Model
  7. {
  8. use HasDateTimeFormatter;
  9. protected $dateFormat = 'U';
  10. protected $host = '';
  11. protected static function booted()
  12. {
  13. static::addGlobalScope('orderById', function (Builder $builder) {
  14. $builder->orderBy((new static())->getTable().'.id', 'desc');
  15. });
  16. }
  17. public function __construct(array $attributes = [])
  18. {
  19. parent::__construct($attributes);
  20. $this->host = env('APP_URL');
  21. }
  22. }