| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\DB;
- class AccountLoginDomain extends Model
- {
- const TABLE = 'QPAccountsDB.dbo.AccountLoginDomain';
- protected $table = self::TABLE;
- public $timestamps = false;
- protected $fillable = [
- 'UserID',
- 'Channel',
- 'Domain',
- 'Scheme',
- 'UpdatedAt',
- 'CreatedAt',
- ];
- public static function record($userId, $origin, $channel = 0)
- {
- $userId = (int) $userId;
- $channel = (int) $channel;
- $origin = trim((string) $origin);
- if ($userId <= 0 || $origin === '') {
- return false;
- }
- $now = date('Y-m-d H:i:s');
- return DB::connection('write')->table(self::TABLE)->updateOrInsert(
- ['UserID' => $userId],
- [
- 'Channel' => $channel,
- 'Domain' => $origin,
- 'Scheme' => '',
- 'UpdatedAt' => $now,
- ]
- );
- }
- }
|