<?php

namespace App\Models;

use App\Enums\OriginStatusType;
use App\Models\Traits\Filterable;
use App\Models\Traits\SelectOptions;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Bank extends Model
{
  use HasFactory, SoftDeletes, Filterable, SelectOptions;

  protected $fillable = [
    'code',
    'name',
    'bi_fast',
    'limit_transfer_amount',
    'status',
  ];

  protected $casts = [
    'status' => OriginStatusType::class,
  ];

  public function userBanks()
  {
    return $this->hasMany(UserBank::class, 'bank_id');
  }

  public function users()
  {
    return $this->belongsToMany(User::class, 'user_banks', 'bank_id', 'user_id');
  }
}
