AccountLoginDomain.php 925 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Support\Facades\DB;
  5. class AccountLoginDomain extends Model
  6. {
  7. const TABLE = 'QPAccountsDB.dbo.AccountLoginDomain';
  8. protected $table = self::TABLE;
  9. public $timestamps = false;
  10. protected $fillable = [
  11. 'UserID',
  12. 'Domain',
  13. 'Scheme',
  14. 'UpdatedAt',
  15. 'CreatedAt',
  16. ];
  17. public static function record($userId, $origin)
  18. {
  19. $userId = (int) $userId;
  20. $origin = trim((string) $origin);
  21. if ($userId <= 0 || $origin === '') {
  22. return false;
  23. }
  24. $now = date('Y-m-d H:i:s');
  25. return DB::connection('write')->table(self::TABLE)->updateOrInsert(
  26. ['UserID' => $userId],
  27. [
  28. 'Domain' => $origin,
  29. 'Scheme' => '',
  30. 'UpdatedAt' => $now,
  31. ]
  32. );
  33. }
  34. }