<?php

namespace App\Models;

use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class Member extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword, ModelTrait;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'members';

    protected $guarded = ['password_confirmation'];

    protected $hidden = [
        'password',
    ];

    /**
     * 所属会员组
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function group()
    {
        return $this->belongsTo(MemberGroup::class, 'group_id');
    }

    public function langs()
    {
        return $this->hasOne(Lang::class, 'slug', 'lang');
    }
}
