add foreign keys and extend models
This commit is contained in:
@ -2,8 +2,11 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
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
|
||||
{
|
||||
@ -24,4 +27,16 @@ class Device extends Model
|
||||
|
||||
//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');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user