<?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 Vendor extends Model
{
  use HasFactory, SoftDeletes, Filterable, SelectOptions;

  protected $fillable = [
    'name',
    'company_name',
    'phone',
    'address',
    'city',
    'status',
  ];

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

  public function userVendors()
  {
    return $this->hasMany(UserVendor::class, 'vendor_id');
  }

  public function transactions()
  {
    return $this->hasMany(Transaction::class, 'vendor_id');
  }
}
