<?php

namespace Modules\Account\Models;

use Illuminate\Database\Eloquent\Model;

class FamilyMember extends Model
{
    protected $table = 'account_family_members';
    protected $fillable = [
        'family_id',
        'user_id'
    ];
    protected $dateFormat = 'Y-m-d H:i:s';

    protected function casts(): array
    {
        return [
            'created_at' => 'datetime:Y-m-d H:i:s',
            'updated_at' => 'datetime:Y-m-d H:i:s',
        ];
    }

    /**
     * 所属家庭
     */
    public function family()
    {
        return $this->belongsTo(Family::class);
    }

    /**
     * 成员用户
     */
    public function user()
    {
        return $this->belongsTo(\Modules\Member\Models\Member::class, 'user_id', 'uid');
    }
}
