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

View File

@ -116,7 +116,8 @@
"twig/twig": "^3.14", "twig/twig": "^3.14",
"twilio/sdk": "^6.40", "twilio/sdk": "^6.40",
"wikimedia/composer-merge-plugin": "^2.1", "wikimedia/composer-merge-plugin": "^2.1",
"wildbit/postmark-php": "^4.0" "wildbit/postmark-php": "^4.0",
"invoiceninja/admin-api": "dev-main"
}, },
"require-dev": { "require-dev": {
"barryvdh/laravel-debugbar": "^3.6", "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", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "4361272676d998d08fb1926198065b39", "content-hash": "f6635e28eff8ba2e1ba889d1ef9dd2d6",
"packages": [ "packages": [
{ {
"name": "adrienrn/php-mimetyper", "name": "adrienrn/php-mimetyper",
@ -4507,22 +4507,22 @@
}, },
{ {
"name": "imdhemy/laravel-purchases", "name": "imdhemy/laravel-purchases",
"version": "1.16.0", "version": "1.17.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/imdhemy/laravel-in-app-purchases.git", "url": "https://github.com/imdhemy/laravel-in-app-purchases.git",
"reference": "91da08e5f87a07c6fb13113a424ca95773ff2e5e" "reference": "54a93cfad81e9c55b06f28a2d2492babf8070ec7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/imdhemy/laravel-in-app-purchases/zipball/91da08e5f87a07c6fb13113a424ca95773ff2e5e", "url": "https://api.github.com/repos/imdhemy/laravel-in-app-purchases/zipball/54a93cfad81e9c55b06f28a2d2492babf8070ec7",
"reference": "91da08e5f87a07c6fb13113a424ca95773ff2e5e", "reference": "54a93cfad81e9c55b06f28a2d2492babf8070ec7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-json": "*", "ext-json": "*",
"ext-openssl": "*", "ext-openssl": "*",
"imdhemy/appstore-iap": "^1.6", "imdhemy/appstore-iap": "^1.8",
"imdhemy/google-play-billing": "^1.5", "imdhemy/google-play-billing": "^1.5",
"laravel/framework": ">=8.0", "laravel/framework": ">=8.0",
"php": ">=8.1" "php": ">=8.1"
@ -4573,7 +4573,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/imdhemy/laravel-in-app-purchases/issues", "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": [ "funding": [
{ {
@ -4581,7 +4581,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2025-02-08T22:31:12+00:00" "time": "2025-06-03T11:22:45+00:00"
}, },
{ {
"name": "intervention/image", "name": "intervention/image",
@ -4667,6 +4667,65 @@
], ],
"time": "2022-05-21T17:30:32+00:00" "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", "name": "invoiceninja/einvoice",
"version": "dev-main", "version": "dev-main",
@ -5319,16 +5378,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v11.45.0", "version": "v11.45.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "d0730deb427632004d24801be7ca1ed2c10fbc4e" "reference": "b09ba32795b8e71df10856a2694706663984a239"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/d0730deb427632004d24801be7ca1ed2c10fbc4e", "url": "https://api.github.com/repos/laravel/framework/zipball/b09ba32795b8e71df10856a2694706663984a239",
"reference": "d0730deb427632004d24801be7ca1ed2c10fbc4e", "reference": "b09ba32795b8e71df10856a2694706663984a239",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -5530,7 +5589,7 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "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", "name": "laravel/octane",
@ -8301,16 +8360,16 @@
}, },
{ {
"name": "nette/utils", "name": "nette/utils",
"version": "v4.0.6", "version": "v4.0.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nette/utils.git", "url": "https://github.com/nette/utils.git",
"reference": "ce708655043c7050eb050df361c5e313cf708309" "reference": "e67c4061eb40b9c113b218214e42cb5a0dda28f2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/ce708655043c7050eb050df361c5e313cf708309", "url": "https://api.github.com/repos/nette/utils/zipball/e67c4061eb40b9c113b218214e42cb5a0dda28f2",
"reference": "ce708655043c7050eb050df361c5e313cf708309", "reference": "e67c4061eb40b9c113b218214e42cb5a0dda28f2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -8381,9 +8440,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/nette/utils/issues", "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", "name": "nikic/php-parser",
@ -17971,16 +18030,16 @@
}, },
{ {
"name": "filp/whoops", "name": "filp/whoops",
"version": "2.18.0", "version": "2.18.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/filp/whoops.git", "url": "https://github.com/filp/whoops.git",
"reference": "a7de6c3c6c3c022f5cfc337f8ede6a14460cf77e" "reference": "8fcc6a862f2e7b94eb4221fd0819ddba3d30ab26"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/filp/whoops/zipball/a7de6c3c6c3c022f5cfc337f8ede6a14460cf77e", "url": "https://api.github.com/repos/filp/whoops/zipball/8fcc6a862f2e7b94eb4221fd0819ddba3d30ab26",
"reference": "a7de6c3c6c3c022f5cfc337f8ede6a14460cf77e", "reference": "8fcc6a862f2e7b94eb4221fd0819ddba3d30ab26",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -18030,7 +18089,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/filp/whoops/issues", "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": [ "funding": [
{ {
@ -18038,7 +18097,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2025-03-15T12:00:00+00:00" "time": "2025-06-03T18:56:14+00:00"
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
@ -21398,7 +21457,8 @@
"beganovich/snappdf": 20, "beganovich/snappdf": 20,
"horstoeko/orderx": 20, "horstoeko/orderx": 20,
"invoiceninja/einvoice": 20, "invoiceninja/einvoice": 20,
"socialiteproviders/apple": 20 "socialiteproviders/apple": 20,
"invoiceninja/admin-api": 20
}, },
"prefer-stable": true, "prefer-stable": true,
"prefer-lowest": false, "prefer-lowest": false,