<?php

namespace App\Models;

use Illuminate\Auth\Authenticatable as AuthAuthenticatableTraits;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Login extends Model implements Authenticatable
{
    use AuthAuthenticatableTraits;
    use HasFactory;

    protected $table = 'login';

    protected $fillable = [

        'username',
        'password',
        'id_role',
    ];

    public function user_detail()
    {
        return $this->hasOne(User_Detail::class, 'id_login');
    }

    public function farm()
    {
        return $this->hasOne(Farm::class, 'login_id');
    }

    public function role()
    {
        return $this->belongsTo(Role::class, 'id_role', 'id');
    }

    // In User_Detail model
    public function login()
    {
        return $this->belongsTo(Login::class, 'id_login');
    }
}
