<?php

declare(strict_types=1);

namespace App\Model;

use Hyperf\Database\Model\Relations\BelongsTo;
use Hyperf\DbConnection\Model\Model;

/**
 * @property int $id
 * @property int $user_id
 * @property string $scope_type
 * @property int $scope_id
 * @property \Carbon\Carbon $created_at
 */
class UserDataScope extends Model
{
    protected ?string $table = 'user_data_scopes';

    public bool $timestamps = false;

    protected array $fillable = [
        'user_id',
        'scope_type',
        'scope_id',
    ];

    protected array $casts = [
        'id' => 'integer',
        'user_id' => 'integer',
        'scope_id' => 'integer',
        'created_at' => 'datetime',
    ];

    /**
     * 所属用户
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class, 'user_id');
    }
}
