rework components
This commit is contained in:
@ -7,11 +7,19 @@ 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
|
||||
@ -25,18 +33,20 @@ class Device extends Model
|
||||
*/
|
||||
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() {
|
||||
return $this->hasMany(OwnerTransaction::class, 'device_id');
|
||||
public function owners(): HasMany {
|
||||
return $this->hasMany(OwnerTransaction::class, 'device_id', 'device_id');
|
||||
}
|
||||
|
||||
public function locations() {
|
||||
return $this->hasMany(LocationTransaction::class, 'device_id');
|
||||
public function locations(): HasMany {
|
||||
return $this->hasMany(LocationTransaction::class, 'device_id', 'device_id');
|
||||
}
|
||||
|
||||
public function purchasing() {
|
||||
return $this->belongsTo(PurchasingInformation::class, 'device_id');
|
||||
public function purchasing(): HasOne {
|
||||
return $this->hasOne(PurchasingInformation::class, 'device_id', 'device_id');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user