Add the ability to list existing Customers Groups

The ability to add new groups and update existing ones has not been implemented yet.
This commit is contained in:
Antoine Le Gonidec 2024-07-16 17:16:41 +02:00
parent 5beaf94f3a
commit 7e749d7cf4
Signed by: vv221
GPG key ID: 636B78F91CEB80D8
3 changed files with 57 additions and 0 deletions

View file

@ -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
}
}

View file

@ -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');
}
);

View file

@ -0,0 +1,34 @@
<?php
/*
SPDX-License-Identifier: AGPL-3.0-only
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
?>
@extends('layouts.app')
@section('title', __('Manage Customers Groups'))
@section('content')
<div class="container">
<div class="flexy-container">
<div class="flexy-item">
<span class="heading">{{ __('Customers Groups') }}</span>
</div>
<div class="flexy-item margin-left">
<a href="{{ route('groups.create') }}" class="btn btn-bordered">{{ __('New Customers Group') }}</a>
</div>
<div class="flexy-block"></div>
</div>
<div class="card-list margin-top">
@foreach ($groups as $group)
<a
href="{{ route('groups.update', [ 'id' => $group->id ] ) }}"
class="card no-img hover-shade"
>
<h4>{{ $group->name }}</h4>
</a>
@endforeach
</div>
</div>
@endsection