Conditions | 4 |
Paths | 6 |
Total Lines | 33 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 18 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php namespace Distilleries\Expendable\Models; |
||
22 | 6 | public function getArea() |
|
23 | { |
||
24 | 6 | $roles = Role::all(); |
|
25 | 6 | $services = Service::orderBy('action')->get(); |
|
26 | 6 | $services = $services->toArray(); |
|
27 | |||
28 | 6 | $groupedServices = []; |
|
29 | |||
30 | 6 | foreach ($services as $service) |
|
31 | { |
||
32 | 6 | $actions = preg_split('/@/', $service['action']); |
|
|
|||
33 | |||
34 | 6 | if (count($actions) >= 2) |
|
35 | { |
||
36 | 2 | $groupedServices[$actions[0]][] = [ |
|
37 | 2 | 'id' => $service['id'], |
|
38 | 2 | 'libelle' => $actions[1] |
|
39 | ]; |
||
40 | } |
||
41 | |||
42 | } |
||
43 | |||
44 | 6 | $result = []; |
|
45 | 6 | foreach ($roles as $role) |
|
46 | { |
||
47 | 6 | $result[] = [ |
|
48 | 6 | 'libelle' => $role->libelle, |
|
49 | 6 | 'id' => $role->id, |
|
50 | 6 | 'choices' => $groupedServices |
|
51 | ]; |
||
52 | } |
||
53 | |||
54 | 6 | return $result; |
|
55 | } |
||
77 | } |