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

34 lines
783 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. public function __construct(array $attributes = [])
  12. {
  13. parent::__construct($attributes);
  14. $this->host = env('APP_URL');
  15. }
  16. //默认按id desc排序
  17. protected static function booted()
  18. {
  19. static::addGlobalScope('orderById', function (Builder $builder) {
  20. $builder->orderBy((new static())->getTable().'.id', 'desc');
  21. });
  22. }
  23. //供应商、代理商、地接、后台管理员等密码加密
  24. protected function passMd5($value): string
  25. {
  26. return md5('9e97ae0d950a4b10182c99d484b204c8' . $value);
  27. }
  28. }