From 7e749d7cf472c2082055d9a917acc3ada62c7809 Mon Sep 17 00:00:00 2001 From: Antoine Le Gonidec Date: Tue, 16 Jul 2024 17:16:41 +0200 Subject: [PATCH] Add the ability to list existing Customers Groups The ability to add new groups and update existing ones has not been implemented yet. --- .../Controllers/CustomersGroupsController.php | 21 ++++++++++++ Http/routes.php | 2 ++ Resources/views/groups/list.blade.php | 34 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 Resources/views/groups/list.blade.php diff --git a/Http/Controllers/CustomersGroupsController.php b/Http/Controllers/CustomersGroupsController.php index f0e06d6..d1a0e46 100644 --- a/Http/Controllers/CustomersGroupsController.php +++ b/Http/Controllers/CustomersGroupsController.php @@ -8,8 +8,29 @@ namespace Modules\MMFCustomersGroups\Http\Controllers; use Illuminate\Routing\Controller; +use Modules\MMFCustomersGroups\Entities\CustomersGroup; + class CustomersGroupsController extends Controller { public function list() { + // Get the list of Mailboxes the current User is allowed to access. + $user = auth()->user(); + $mailboxes = $user->mailboxesIdsCanView(); + + // Get the list of Customers Groups, filtered by Mailbox. + $groups = CustomersGroup + ::whereIn('mailbox_id', $mailboxes) + ->get(); + + return view('mmfcustomersgroups::groups/list', [ + 'groups' => $groups, + ]); + } + + public function create() { + // TODO + } + + public function update() { // TODO } } diff --git a/Http/routes.php b/Http/routes.php index 2dc0795..6114f3b 100644 --- a/Http/routes.php +++ b/Http/routes.php @@ -14,5 +14,7 @@ Route::group( ], function() { Route::get('/groups/list', ['uses' => CustomersGroupsController::class . '@list', 'laroute' => true])->name('groups.list'); + Route::get('/groups/create', ['uses' => CustomersGroupsController::class . '@create', 'laroute' => true])->name('groups.create'); + Route::get('/groups/update', ['uses' => CustomersGroupsController::class . '@update', 'laroute' => true])->name('groups.update'); } ); diff --git a/Resources/views/groups/list.blade.php b/Resources/views/groups/list.blade.php new file mode 100644 index 0000000..79a3183 --- /dev/null +++ b/Resources/views/groups/list.blade.php @@ -0,0 +1,34 @@ + + */ +?> + +@extends('layouts.app') + +@section('title', __('Manage Customers Groups')) + +@section('content') +
+
+
+ {{ __('Customers Groups') }} +
+ +
+
+
+ @foreach ($groups as $group) + +

{{ $group->name }}

+
+ @endforeach +
+
+@endsection