<?php

namespace App\Models;

use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Branch extends Model
{
    use SoftDeletes, LogsActivity;

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'id','name_km','name_en','phone','address' ,'image','image1','province_id','district_id','commune_id','village_id','branch_code','branch_prefix','client_prefix','co_prefix','user_prefix','loan_prefix','invoice_prefix','status_id'
    ];

    public function village()
    {
        return $this->belongsTo(Village::class,'village_id');
    }

    public function UserBranRepre()
    {
        return $this->hasOne(User::class,'representative_branch_id');
    }
}
