<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Bidders extends Model
{
    protected $table = 'bidders';
    
    protected $primaryKey = 'idbidders';

    protected $fillable = [
      'bidder_fname',
      'bidder_lname',
      'bidder_addr',
      'bidder_city',
      'bidder_state',
      'bidder_zip',
      'bidder_phone',
      'bidder_email',
      'bidder_assigned_number',
      'created_at',
      'updated_at'
    ];

    protected function casts(): array
    {
        return [
            'created_at' => 'datetime',
            'updated_at' => 'datetime',
        ];
    }

    public function checkout()
    {
        return $this->hasMany('App\Models\Checkout', 'bidder_num', 'idbidders');
    }

    public function winningBids()
    {
        return $this->hasMany('App\Models\WinningBids', 'winning_bidder_num', 'idbidders');
    }

    public function vehicles()
    {
        return $this->hasMany(Vehicles::class, 'owner', 'bidder_assigned_number');
    }
}
