SystemSettings::body()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 12
c 0
b 0
f 0
nc 6
nop 0
dl 0
loc 23
rs 9.8666
1
<?php
2
3
namespace Epesi\Core\System;
4
5
use Epesi\Core\System\Modules\ModuleView;
6
use Epesi\Core\System\Integration\Joints\SystemSettingsJoint;
7
use Illuminate\Support\Facades\Auth;
8
9
class SystemSettings extends ModuleView
10
{
11
	protected $label = 'System Administration';
12
	
13
	public static function access()
14
	{
15
		return Auth::user()->can('modify system settings');
16
	}
17
	
18
	public function body()
19
	{
20
		$layout = \atk4\ui\View::addTo($this)->addStyle('max-width:1200px;margin:auto;');
21
		\atk4\ui\Header::addTo($layout, [__($this->label)]);
22
		$segment = \atk4\ui\View::addTo($layout, ['ui' => 'segment']);
23
24
		$sections = [];
25
		/**
26
		 * @var SystemSettingsJoint $joint
27
		 */
28
		foreach (SystemSettingsJoint::collect() as $joint) {
29
			$sections[$joint->section()][$joint->label()] = $joint;
30
		}
31
32
		ksort($sections);
33
		
34
		foreach ($sections as $sectionName => $sectionJoints) {
35
			\atk4\ui\Header::addTo($segment, [$sectionName]);
36
			
37
			ksort($sectionJoints);
38
			
39
			foreach ($sectionJoints as $joint) {
40
				$segment->add($joint->button());
41
			}
42
		}
43
	}
44
}
45