1<?php 2 3namespace App\Models; 4 5use Illuminate\Database\Eloquent\Model; 6use Illuminate\Database\Eloquent\Relations\HasMany; 7use LibreNMS\Interfaces\Models\Keyable; 8 9class MplsSap extends Model implements Keyable 10{ 11 protected $primaryKey = 'sap_id'; 12 public $timestamps = false; 13 protected $fillable = [ 14 'svc_id', 15 'svc_oid', 16 'sapPortId', 17 'ifName', 18 'sapEncapValue', 19 'device_id', 20 'sapRowStatus', 21 'sapType', 22 'sapDescription', 23 'sapAdminStatus', 24 'sapOperStatus', 25 'sapLastMgmtChange', 26 'sapLastStatusChange', 27 ]; 28 29 // ---- Helper Functions ---- 30 31 /** 32 * Get a string that can identify a unique instance of this model 33 * @return string 34 */ 35 public function getCompositeKey() 36 { 37 return $this->svc_oid . '-' . $this->sapPortId . '-' . $this->sapEncapValue; 38 } 39 40 // ---- Define Relationships ---- 41 42 public function binds(): HasMany 43 { 44 return $this->hasMany(\App\Models\MplsSdpBind::class, 'svc_id'); 45 } 46 47 public function services(): HasMany 48 { 49 return $this->hasMany(\App\Models\MplsService::class, 'svc_id'); 50 } 51} 52