abschlussprojekt-device-man.../device-app/app/Models/Device.php
2023-03-30 15:16:38 +02:00

53 lines
1.5 KiB
PHP

<?php
namespace App\Models;
use App\Models\OwnerTransaction;
use App\Models\LocationTransaction;
use App\Models\PurchasingInformation;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
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, HasUuids;
/**
* 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');
}
}