hide excluded fields from client show/edit routes

This commit is contained in:
David Bomba 2025-06-05 09:03:49 +10:00
parent c3711ad226
commit c5cc95f2e4
3 changed files with 97 additions and 33 deletions

View File

@ -112,10 +112,11 @@ class ClientController extends BaseController
*/
public function show(ShowClientRequest $request, Client $client)
{
nlog("show");
if(auth()->user()->hasExcludedPermissions($this->client_excludable_permissions, $this->client_excludable_overrides)){
nlog('hiding fields');
$client->makeHidden($this->client_exclusion_fields);
foreach($this->client_exclusion_fields as $field){
$client->{$field} = null;
}
}
return $this->itemResponse($client);
@ -131,11 +132,13 @@ class ClientController extends BaseController
*/
public function edit(EditClientRequest $request, Client $client)
{
nlog("Edit");
if (auth()->user()->hasExcludedPermissions($this->client_excludable_permissions, $this->client_excludable_overrides)) {
nlog('hiding fields');
$client->makeHidden($this->client_exclusion_fields);
foreach ($this->client_exclusion_fields as $field) {
$client->{$field} = null;
}
}
return $this->itemResponse($client);
}

View File

@ -116,7 +116,8 @@
"twig/twig": "^3.14",
"twilio/sdk": "^6.40",
"wikimedia/composer-merge-plugin": "^2.1",
"wildbit/postmark-php": "^4.0"
"wildbit/postmark-php": "^4.0",
"invoiceninja/admin-api": "dev-main"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.6",

112
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4361272676d998d08fb1926198065b39",
"content-hash": "f6635e28eff8ba2e1ba889d1ef9dd2d6",
"packages": [
{
"name": "adrienrn/php-mimetyper",
@ -4507,22 +4507,22 @@
},
{
"name": "imdhemy/laravel-purchases",
"version": "1.16.0",
"version": "1.17.0",
"source": {
"type": "git",
"url": "https://github.com/imdhemy/laravel-in-app-purchases.git",
"reference": "91da08e5f87a07c6fb13113a424ca95773ff2e5e"
"reference": "54a93cfad81e9c55b06f28a2d2492babf8070ec7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/imdhemy/laravel-in-app-purchases/zipball/91da08e5f87a07c6fb13113a424ca95773ff2e5e",
"reference": "91da08e5f87a07c6fb13113a424ca95773ff2e5e",
"url": "https://api.github.com/repos/imdhemy/laravel-in-app-purchases/zipball/54a93cfad81e9c55b06f28a2d2492babf8070ec7",
"reference": "54a93cfad81e9c55b06f28a2d2492babf8070ec7",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-openssl": "*",
"imdhemy/appstore-iap": "^1.6",
"imdhemy/appstore-iap": "^1.8",
"imdhemy/google-play-billing": "^1.5",
"laravel/framework": ">=8.0",
"php": ">=8.1"
@ -4573,7 +4573,7 @@
],
"support": {
"issues": "https://github.com/imdhemy/laravel-in-app-purchases/issues",
"source": "https://github.com/imdhemy/laravel-in-app-purchases/tree/1.16.0"
"source": "https://github.com/imdhemy/laravel-in-app-purchases/tree/1.17.0"
},
"funding": [
{
@ -4581,7 +4581,7 @@
"type": "github"
}
],
"time": "2025-02-08T22:31:12+00:00"
"time": "2025-06-03T11:22:45+00:00"
},
{
"name": "intervention/image",
@ -4667,6 +4667,65 @@
],
"time": "2022-05-21T17:30:32+00:00"
},
{
"name": "invoiceninja/admin-api",
"version": "dev-main",
"dist": {
"type": "path",
"url": "../admin-api",
"reference": "1ba06bff5aa7fd37ad607431fa71d4a1652f97d8"
},
"require": {
"afosto/yaac": "^1.5",
"asm/php-ansible": "dev-main",
"ext-curl": "*",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-simplexml": "*",
"illuminate/database": "^11",
"illuminate/support": "^11",
"imdhemy/laravel-purchases": "^1.7",
"php": "^8.2|^8.3|^8.4"
},
"require-dev": {
"larastan/larastan": "^3.0",
"orchestra/testbench": "^9.0",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^11.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"InvoiceNinja\\AdminApi\\Providers\\AdminApiServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"InvoiceNinja\\AdminApi\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"InvoiceNinja\\AdminApi\\Tests\\": "tests/"
}
},
"license": [
"Elastic"
],
"authors": [
{
"name": "David Bomba",
"email": "turbo124@gmail.com"
}
],
"description": "API endpoints for the admin interface",
"transport-options": {
"relative": true
}
},
{
"name": "invoiceninja/einvoice",
"version": "dev-main",
@ -5319,16 +5378,16 @@
},
{
"name": "laravel/framework",
"version": "v11.45.0",
"version": "v11.45.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "d0730deb427632004d24801be7ca1ed2c10fbc4e"
"reference": "b09ba32795b8e71df10856a2694706663984a239"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/d0730deb427632004d24801be7ca1ed2c10fbc4e",
"reference": "d0730deb427632004d24801be7ca1ed2c10fbc4e",
"url": "https://api.github.com/repos/laravel/framework/zipball/b09ba32795b8e71df10856a2694706663984a239",
"reference": "b09ba32795b8e71df10856a2694706663984a239",
"shasum": ""
},
"require": {
@ -5530,7 +5589,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2025-05-20T15:15:58+00:00"
"time": "2025-06-03T14:01:40+00:00"
},
{
"name": "laravel/octane",
@ -8301,16 +8360,16 @@
},
{
"name": "nette/utils",
"version": "v4.0.6",
"version": "v4.0.7",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "ce708655043c7050eb050df361c5e313cf708309"
"reference": "e67c4061eb40b9c113b218214e42cb5a0dda28f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/ce708655043c7050eb050df361c5e313cf708309",
"reference": "ce708655043c7050eb050df361c5e313cf708309",
"url": "https://api.github.com/repos/nette/utils/zipball/e67c4061eb40b9c113b218214e42cb5a0dda28f2",
"reference": "e67c4061eb40b9c113b218214e42cb5a0dda28f2",
"shasum": ""
},
"require": {
@ -8381,9 +8440,9 @@
],
"support": {
"issues": "https://github.com/nette/utils/issues",
"source": "https://github.com/nette/utils/tree/v4.0.6"
"source": "https://github.com/nette/utils/tree/v4.0.7"
},
"time": "2025-03-30T21:06:30+00:00"
"time": "2025-06-03T04:55:08+00:00"
},
{
"name": "nikic/php-parser",
@ -17971,16 +18030,16 @@
},
{
"name": "filp/whoops",
"version": "2.18.0",
"version": "2.18.1",
"source": {
"type": "git",
"url": "https://github.com/filp/whoops.git",
"reference": "a7de6c3c6c3c022f5cfc337f8ede6a14460cf77e"
"reference": "8fcc6a862f2e7b94eb4221fd0819ddba3d30ab26"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/filp/whoops/zipball/a7de6c3c6c3c022f5cfc337f8ede6a14460cf77e",
"reference": "a7de6c3c6c3c022f5cfc337f8ede6a14460cf77e",
"url": "https://api.github.com/repos/filp/whoops/zipball/8fcc6a862f2e7b94eb4221fd0819ddba3d30ab26",
"reference": "8fcc6a862f2e7b94eb4221fd0819ddba3d30ab26",
"shasum": ""
},
"require": {
@ -18030,7 +18089,7 @@
],
"support": {
"issues": "https://github.com/filp/whoops/issues",
"source": "https://github.com/filp/whoops/tree/2.18.0"
"source": "https://github.com/filp/whoops/tree/2.18.1"
},
"funding": [
{
@ -18038,7 +18097,7 @@
"type": "github"
}
],
"time": "2025-03-15T12:00:00+00:00"
"time": "2025-06-03T18:56:14+00:00"
},
{
"name": "friendsofphp/php-cs-fixer",
@ -21398,7 +21457,8 @@
"beganovich/snappdf": 20,
"horstoeko/orderx": 20,
"invoiceninja/einvoice": 20,
"socialiteproviders/apple": 20
"socialiteproviders/apple": 20,
"invoiceninja/admin-api": 20
},
"prefer-stable": true,
"prefer-lowest": false,