Files
librenms-librenms/app/Models/BgpPeer.php
T
PipoCanaja daa8c757f6 Fix a few Db* to Eloquent requests (#14278)
* Eloquent for 2 requests

* Eloquent for 1 request

* a few in Dell

* Model

* and more with timos

* and more with timos

* and firebrick

* firebrick

* one query instead of many

* Should use collection get

* Update timos.inc.php

* Update dell-os10.inc.php

* avoid changing timos as it breaks something

* new try with timos

* deps for BGP

* revert deps for BGP

* style

* style

* deps for BGP, 2nd try

* typo

* revert aos7

* fix create

* firebricktests

* firebrick

* firebrick

* cipsec-fix

* cipsec

* timos fix 100th time :)

* ./scripts/save-test-data.php -m os,ports,processors,mempools,vrf,sensors,bgp-peers,mpls,ospf  -o timos -v 7705

* remove timos from this PR

Co-authored-by: Tony Murray <[email protected]>
2022-10-02 16:04:08 +02:00

64 lines
1.8 KiB
PHP

<?php
/**
* BgpPeer.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @link https://www.librenms.org
*
* @copyright 2018 Tony Murray
* @author Tony Murray <[email protected]>
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class BgpPeer extends DeviceRelatedModel
{
use HasFactory;
public $timestamps = false;
protected $table = 'bgpPeers';
protected $primaryKey = 'bgpPeer_id';
protected $fillable = [
'vrf_id',
'bgpPeerIdentifier',
'bgpPeerRemoteAs',
'bgpPeerState',
'bgpPeerAdminStatus',
'bgpLocalAddr',
'bgpPeerRemoteAddr',
'bgpPeerInUpdates',
'bgpPeerOutUpdates',
'bgpPeerInTotalMessages',
'bgpPeerOutTotalMessages',
'bgpPeerFsmEstablishedTime',
'bgpPeerInUpdateElapsedTime',
'astext',
];
// ---- Query scopes ----
public function scopeInAlarm(Builder $query)
{
return $query->where(function (Builder $query) {
$query->where('bgpPeerAdminStatus', 'start')
->orWhere('bgpPeerAdminStatus', 'running');
})->where('bgpPeerState', '!=', 'established');
}
}