UserBlacklist.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Models\Account;
  3. use App\AdminUser;
  4. use App\Models\AccountsInfo;
  5. use Illuminate\Database\Eloquent\Builder;
  6. use Illuminate\Database\Eloquent\Model;
  7. class UserBlacklist extends Model
  8. {
  9. public const CREATED_AT = 'CreatedAt';
  10. public const UPDATED_AT = 'UpdatedAt';
  11. protected $table = 'QPAccountsDB.dbo.UserBlacklist';
  12. protected $primaryKey = 'ID';
  13. protected static function boot()
  14. {
  15. parent::boot();
  16. static::addGlobalScope('soft_delete', function (Builder $b) {
  17. $b->where('IsDel', 0);
  18. });
  19. }
  20. public function accountsInfo()
  21. {
  22. return $this->belongsTo(AccountsInfo::class, 'UserID', 'UserID');
  23. }
  24. public function admin()
  25. {
  26. return $this->belongsTo(AdminUser::class, 'AdminID', 'id');
  27. }
  28. public function getCreatedAtChinaAttribute()
  29. {
  30. return date('Y-m-d H:i:s', strtotime($this->attributes['CreatedAt'].' +11 hours'));
  31. }
  32. public function getUpdatedAtChinaAttribute()
  33. {
  34. return date('Y-m-d H:i:s', strtotime($this->attributes['UpdatedAt'].' +11 hours'));
  35. }
  36. }