<?php

namespace App\Models;

use App\Http\Controllers\UserBranchController;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class UserBranch extends Model
{
    use HasFactory;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'user_branch';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'user_id',
        'branch_id',
    ];

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    /**
     * Get the user that owns the branch assignment.
     */
    public function user()
    {
        return $this->belongsTo(UserAccount::class, 'user_id');
    }

    /**
     * Get the branch associated with this assignment.
     */
    public function branch()
    {
        return $this->belongsTo(UserBranchController::class, 'branch_id');
    }
}
