From 90206f2bb5d2dff12aef281642b3377bf1eb396d Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 19 Dec 2023 11:16:08 +1100 Subject: [PATCH] Enable admin setting user for a system --- app/Http/Controllers/SystemController.php | 6 +- app/Http/Requests/SystemRegister.php | 1 + .../views/system/widget/form-system.blade.php | 318 ++++++++++-------- resources/views/user/addedit.blade.php | 229 +++++++------ resources/views/user/home.blade.php | 8 +- 5 files changed, 320 insertions(+), 242 deletions(-) diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index dee2057..b3d9739 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -16,7 +16,7 @@ use Illuminate\Support\ViewErrorBag; use App\Classes\FTN\Message; use App\Http\Requests\{AddressMerge,AreafixRequest,SystemRegister}; use App\Jobs\AddressPoll; -use App\Models\{Address,Echoarea,Filearea,Netmail,Setup,System,SystemZone,Zone}; +use App\Models\{Address,Echoarea,Filearea,Netmail,Setup,System,Zone}; use App\Notifications\Netmails\AddressLink; use App\Rules\{FidoInteger,TwoByteInteger}; @@ -49,6 +49,10 @@ class SystemController extends Controller ->transform(function($item) { $item['active'] = Arr::get($item,'active',FALSE); return $item; }); $o->mailers()->sync($mailers); + if ($request->post('users') && array_filter($request->post('users'),function($item) { return $item; })) + $o->users()->sync($request->post('users')); + else + $o->users()->detach(); return redirect()->to('system'); } diff --git a/app/Http/Requests/SystemRegister.php b/app/Http/Requests/SystemRegister.php index 20d1007..69a5653 100644 --- a/app/Http/Requests/SystemRegister.php +++ b/app/Http/Requests/SystemRegister.php @@ -78,6 +78,7 @@ class SystemRegister extends FormRequest 'mailer_details.*.port' => 'nullable|digits_between:2,5', 'zt_id' => 'nullable|size:10|regex:/^([A-Fa-f0-9]){10}$/|unique:systems,zt_id,'.($so->exists ? $so->id : 0), 'pkt_type' => ['required',Rule::in(array_keys(Packet::PACKET_TYPES))], + 'users' => 'nullable|array|min:1|max:2', ] : [], $so->exists ? [ 'active' => 'required|boolean', diff --git a/resources/views/system/widget/form-system.blade.php b/resources/views/system/widget/form-system.blade.php index b3c1432..05d4f6c 100644 --- a/resources/views/system/widget/form-system.blade.php +++ b/resources/views/system/widget/form-system.blade.php @@ -1,155 +1,189 @@ -
- -
- -
- - - -
- - @error('name') - {{ $message }} - @else - A name is required. - @enderror - -
-
+
+
+

System Users

- -
- -
- - - - @error('zt_id') - {{ $message }} - @enderror - -
-
+
+ +
+ +
+ + - -
- @can('update',$o) - -
-
- active))checked @endif> - - - active))checked @endif> - + + @error('users') + {{ $message }} + @enderror +
- @endcan +
- -
- -
- - - - @error('sysop') - {{ $message }} - @else - A Sysop's name is required. - @enderror - -
-
+
+

System Details

- -
- -
- - - - @error('location') - {{ $message }} - @else - System location is required. - @enderror - -
-
- - -
- @can('update',$o) - -
-
- hold))checked @endif> - - - hold))checked @endif> - +
+ +
+ +
+ + + +
+ + @error('name') + {{ $message }} + @else + A name is required. + @enderror +
- @endcan -
-
-
- -
- -
- - - - @error('address') - {{ $message }} - @enderror - -
-
- - -
- -
- - - - @error('phone') - {{ $message }} - @enderror - -
-
- - -
- @can('update',$o) - -
-
- pollmode === TRUE) ? 2 : 0) === 2)checked @endif> - - - pollmode === FALSE) ? 1 : 0) === 1)checked @endif> - - - pollmode) ? 0 : 1) === 0)checked @endif> - + +
+ +
+ + + + @error('zt_id') + {{ $message }} + @enderror +
- - @error('pollmode') - {{ $message }} - @enderror -
- @endcan + + +
+ @can('update',$o) + +
+
+ active))checked @endif> + + + active))checked @endif> + +
+
+ @endcan +
+
+ +
+ +
+ +
+ + + + @error('sysop') + {{ $message }} + @else + A Sysop's name is required. + @enderror + +
+
+ + +
+ +
+ + + + @error('location') + {{ $message }} + @else + System location is required. + @enderror + +
+
+ + +
+ @can('update',$o) + +
+
+ hold))checked @endif> + + + hold))checked @endif> + +
+
+ @endcan +
+
+ +
+ +
+ +
+ + + + @error('address') + {{ $message }} + @enderror + +
+
+ + +
+ +
+ + + + @error('phone') + {{ $message }} + @enderror + +
+
+ + +
+ @can('update',$o) + +
+
+ pollmode === TRUE) ? 2 : 0) === 2)checked @endif> + + + pollmode === FALSE) ? 1 : 0) === 1)checked @endif> + + + pollmode) ? 0 : 1) === 0)checked @endif> + +
+ + @error('pollmode') + {{ $message }} + @enderror + +
+ @endcan +
+
@@ -390,9 +424,19 @@
+@section('page-css') + @css('select2') +@append @section('page-scripts') + @js('select2') +