diff --git a/app/Http/Requests/EntryRequest.php b/app/Http/Requests/EntryRequest.php index 2facca6e..630d5edf 100644 --- a/app/Http/Requests/EntryRequest.php +++ b/app/Http/Requests/EntryRequest.php @@ -10,14 +10,24 @@ class EntryRequest extends FormRequest * Get the validation rules that apply to the request. * * @return array + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface */ public function rules(): array { $r = request() ?: collect(); + $rk = array_keys($r->all()); return config('server') ->schema('attributetypes') - ->intersectByKeys($r->all()) + ->filter(fn($item)=>$item->names_lc->intersect($rk)->count()) + ->transform(function($item) use ($rk) { + // Set the attributetype name + if (($x=$item->names_lc->intersect($rk))->count() === 1) + $item->setName($x->pop()); + + return $item; + }) ->map(fn($item)=>$item->validation($r->get('objectclass',[]))) ->filter() ->flatMap(fn($item)=>$item) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index cbd94227..987713f4 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,7 +2,6 @@ namespace App\Providers; -use Illuminate\Support\Collection; use Illuminate\Support\ServiceProvider; use LdapRecord\Configuration\DomainConfiguration; use LdapRecord\Laravel\LdapRecord; diff --git a/resources/views/components/attribute-type.blade.php b/resources/views/components/attribute-type.blade.php index e1bba96a..68813d4e 100644 --- a/resources/views/components/attribute-type.blade.php +++ b/resources/views/components/attribute-type.blade.php @@ -18,7 +18,7 @@ @endif @if((! $ca) && (! $ct) && $template?->attribute($o->name_lc)) - + @endif @endif