From 0b30f9eae622d3725b41761b051f3c8b7e1270ed Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 10 Mar 2026 15:11:21 +0000 Subject: [PATCH] Added getters --- app/Models/User.php | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/app/Models/User.php b/app/Models/User.php index 406aece1f3..9e462556e3 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -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(