Just optimisations
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use App\Models\{Node,Zone};
|
||||
|
||||
trait GetNode
|
||||
@@ -10,11 +12,19 @@ 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)
|
||||
protected function get_node(array $address,$create=TRUE)
|
||||
{
|
||||
if (! $z=Arr::get($address,'z'))
|
||||
throw new \Exception('Zone cannot be zero');
|
||||
|
||||
$zo = Zone::firstOrCreate(['id'=>$z]);
|
||||
|
||||
$no = Node::firstOrNew(['zone_id'=>$zo->id,'host_id'=>$n,'node_id'=>$f,'point_id'=>$p]);
|
||||
$no = Node::firstOrNew([
|
||||
'zone_id'=>$zo->id,
|
||||
'host_id'=>Arr::get($address,'n'),
|
||||
'node_id'=>Arr::get($address,'f'),
|
||||
'point_id'=>Arr::get($address,'p',0)
|
||||
]);
|
||||
|
||||
if (! $no->exists AND $create)
|
||||
{
|
||||
|
Reference in New Issue
Block a user