<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Bank extends Model
{
    use HasFactory;
    use SoftDeletes;

    protected $fillable = [
        'name',
        'enabled',
        'visibility'
    ];

    public function canDelete()
    {
        return \App\Models\PaymentMethod::where('origin_id', $this->id)->orWhere('destination_id', $this->id)->count() == 0;
    }

    public function getVisibility()
    {
        $ret = '';
        if ($this->visibility == 'IN')
            $ret = "Solo in entrata";
        if ($this->visibility == 'OUT')
            $ret = "Solo in uscita";
        if ($this->visibility == 'ALL')
            $ret = "Entrambi";
        return $ret;
    }

}
