Initial echomail import
This commit is contained in:
32
app/Traits/GetNode.php
Normal file
32
app/Traits/GetNode.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Models\{Node,Zone};
|
||||
|
||||
trait GetNode
|
||||
{
|
||||
/**
|
||||
* Get an FTN record
|
||||
* If the record doesnt exist, we'll create it
|
||||
*/
|
||||
protected function get_node($z,$n,$f,$p=0,$create=TRUE)
|
||||
{
|
||||
$zo = Zone::firstOrCreate(['id'=>$z]);
|
||||
|
||||
$no = Node::firstOrNew(['zone_id'=>$zo->id,'host_id'=>$n,'node_id'=>$f,'point_id'=>$p]);
|
||||
|
||||
if (! $no->exists AND $create)
|
||||
{
|
||||
$no->active = FALSE;
|
||||
$no->system = 'AUTO DISCOVERED';
|
||||
$no->sysop = 'UNKNOWN';
|
||||
$no->location = '';
|
||||
$no->baud = 0;
|
||||
|
||||
$no->save();
|
||||
}
|
||||
|
||||
return ($no->exists) ? $no : NULL;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user