<?php

namespace App\Models;

use App\Models\OwnerTransaction;
use App\Models\LocationTransaction;
use App\Models\PurchasingInformation;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Device extends Model
{
    use HasFactory;

    /**
     * The primary key associated with the devices table.
     * @var string
     */
    protected $primaryKey = 'device_id';

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = ['device_id', 'title', 'device_type', 'description', 'accessories', 'rz_username_buyer', 'serial_number', 'image_url'];

    //Timestamps are disabled.
    public $timestamps = false;

    public function owners() {
        return $this->hasMany(OwnerTransaction::class, 'device_id');
    }

    public function locations() {
        return $this->hasMany(LocationTransaction::class, 'device_id');
    }

    public function purchasing() {
        return $this->belongsTo(PurchasingInformation::class, 'device_id');
    }
}