<?php

namespace App\Models;

use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class UserThirdParty extends BaseModel
{
    protected $table = 'user_third_party';

    public const CREATED_AT = 'create_time';

    public const UPDATED_AT = 'update_time';

    protected $fillable = [
        'user_id',
        'platform',
        'open_id',
        'union_id',
        'nickname',
        'avatar',
        'access_token',
        'refresh_token',
        'expires_at',
        'raw_data',
    ];

    protected $casts = [
        'expires_at' => 'datetime',
        'raw_data' => 'array',
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class, 'user_id');
    }
}
