Enable ZC to see netmail in their zone, and point owners to see their own netmail
This commit is contained in:
@@ -6,6 +6,7 @@ use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
use App\Traits\{ScopeActive,UserSwitch};
|
||||
@@ -91,6 +92,31 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
*/
|
||||
public function isZC(): bool
|
||||
{
|
||||
return $this->systems->pluck('addresses')->flatten()->where('role',Address::NODE_ZC)->count() > 0;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user