2023-03-29 22:32:49 +02:00

52 lines
1.4 KiB
PHP

<?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;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
class Device extends Model
{
use HasFactory;
/**
* The table associated with the model.
* @var string
*/
protected $table = 'devices';
/**
* 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'];
//The data type of the auto-incrementing ID.
protected $keyType = 'string';
//Timestamps are disabled.
public $timestamps = false;
public function owners(): HasMany {
return $this->hasMany(OwnerTransaction::class, 'device_id', 'device_id');
}
public function locations(): HasMany {
return $this->hasMany(LocationTransaction::class, 'device_id', 'device_id');
}
public function purchasing(): HasOne {
return $this->hasOne(PurchasingInformation::class, 'device_id', 'device_id');
}
}