Added getters

This commit is contained in:
snipe
2026-03-10 15:11:21 +00:00
parent 8f6782bdfa
commit 0b30f9eae6

View File

@@ -208,6 +208,68 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* @return Attribute
*/
/**
* These fields should be hidden if the requesting user cannot view contact info
* @return Attribute
*/
protected function address(): Attribute
{
return Attribute:: make(
get: fn(mixed $value) => (auth()->user() && auth()->user()->can('manageContactInfo')) ? $value : null,
);
}
protected function city(): Attribute
{
return Attribute:: make(
get: fn(mixed $value) => (auth()->user() && auth()->user()->can('manageContactInfo')) ? $value : null,
);
}
protected function state(): Attribute
{
return Attribute:: make(
get: fn(mixed $value) => (auth()->user() && auth()->user()->can('manageContactInfo')) ? $value : null,
);
}
protected function country(): Attribute
{
return Attribute:: make(
get: fn(mixed $value) => (auth()->user() && auth()->user()->can('manageContactInfo')) ? $value : null,
);
}
protected function zip(): Attribute
{
return Attribute:: make(
get: fn(mixed $value) => (auth()->user() && auth()->user()->can('manageContactInfo')) ? $value : null,
);
}
protected function phone(): Attribute
{
return Attribute:: make(
get: fn(mixed $value) => (auth()->user() && auth()->user()->can('manageContactInfo')) ? $value : null,
);
}
protected function mobile(): Attribute
{
return Attribute:: make(
get: fn(mixed $value) => (auth()->user() && auth()->user()->can('manageContactInfo')) ? $value : null,
);
}
protected function website(): Attribute
{
return Attribute:: make(
get: fn(mixed $value) => (auth()->user() && auth()->user()->can('manageContactInfo')) ? $value : null,
);
}
protected function displayName(): Attribute
{
return Attribute:: make(