'datetime', 'last_on' => 'datetime:Y-m-d H:i:s' ]; /* RELATIONS */ public function system() { return $this->belongsTo(System::class); } public function systems() { return $this->belongsToMany(System::class); } /* GENERAL METHODS */ public function addresses(): Collection { return Address::select('addresses.*') ->join('systems',['systems.id'=>'addresses.system_id']) ->join('system_user',['system_user.system_id'=>'systems.id']) ->where('system_user.user_id',$this->id) ->with(['zone.domain']) ->get(); } /** * See if the user is already a member of the chosen network * * @param Domain $o * @return bool */ public function isMember(Domain $o): bool { return FALSE; } /** * Is this user a ZC of a domain? * * @return bool */ public function isZC(): bool { $this->load(['systems.addresses']); return $this->zc()->count() > 0; } /** * Return the zones that this user is ZC for * * @return Collection */ public function points(): Collection { $result = collect(); foreach($this->systems->pluck('addresses')->flatten()->where('role','>',Address::NODE_HC) as $ao) $result = $result->merge($ao->children()); return $result; } /** * Return the zones that this user is ZC for * * @return Collection */ public function zc(): Collection { return $this->systems->pluck('addresses')->flatten()->where('role',Address::NODE_ZC); } }