| Code Coverage
| Lines | Functions and Methods | Classes and Traits
Total | 0.00% covered (danger) | 0.00% | 0 / 26 | 0.00% covered (danger) | 0.00% | 0 / 5 | CRAP | 0.00% covered (danger) | 0.00% | 0 / 1
GroupsController | 0.00% covered (danger) | 0.00% | 0 / 26 | 0.00% covered (danger) | 0.00% | 0 / 5 | 90 | 0.00% covered (danger) | 0.00% | 0 / 1
index | 0.00% covered (danger) | 0.00% | 0 / 2 | 0.00% covered (danger) | 0.00% | 0 / 1 | 2 |
new | 0.00% covered (danger) | 0.00% | 0 / 2 | 0.00% covered (danger) | 0.00% | 0 / 1 | 2 |
create | 0.00% covered (danger) | 0.00% | 0 / 9 | 0.00% covered (danger) | 0.00% | 0 / 1 | 6 |
edit | 0.00% covered (danger) | 0.00% | 0 / 4 | 0.00% covered (danger) | 0.00% | 0 / 1 | 12 |
update | 0.00% covered (danger) | 0.00% | 0 / 9 | 0.00% covered (danger) | 0.00% | 0 / 1 | 6 |

1 | <?php
2 |
3 | namespace App\Controllers;
4 |
5 | class GroupsController extends BaseController
6 | {
7 | public function index(): string
8 | {
9 | $data = service('academyCatalog')->getGroupsIndexData($this->request->getGet(), auth()->user());
10 |
11 | return view('groups/index', $data);
12 | }
13 |
14 | public function new(): string
15 | {
16 | $data = service('academyCatalog')->getGroupFormData();
17 |
18 | return view('groups/form', $data);
19 | }
20 |
21 | public function create()
22 | {
23 | $result = service('academyCatalog')->saveGroup($this->request->getPost());
24 |
25 | if (! $result['success']) {
26 | $data = service('academyCatalog')->getGroupFormData(
27 | null,
28 | $this->request->getPost(),
29 | $result['errors'] ?? [],
30 | );
31 |
32 | return view('groups/form', $data);
33 | }
34 |
35 | return redirect()->to(url_to('groups.index'))->with('message', 'Grupa a fost adaugata.');
36 | }
37 |
38 | public function edit(int $groupId)
39 | {
40 | $data = service('academyCatalog')->getGroupFormData($groupId);
41 |
42 | if ($data === null || $data['group'] === null) {
43 | return $this->forbidden('Grupa solicitata nu a fost gasita.');
44 | }
45 |
46 | return view('groups/form', $data);
47 | }
48 |
49 | public function update(int $groupId)
50 | {
51 | $result = service('academyCatalog')->saveGroup($this->request->getPost(), $groupId);
52 |
53 | if (! $result['success']) {
54 | $data = service('academyCatalog')->getGroupFormData(
55 | $groupId,
56 | $this->request->getPost(),
57 | $result['errors'] ?? [],
58 | );
59 |
60 | return view('groups/form', $data);
61 | }
62 |
63 | return redirect()->to(url_to('groups.index'))->with('message', 'Grupa a fost actualizata.');
64 | }
65 | }