Passed
Push — master ( e4e152...8fde47 )
by Georgi
02:55
created

SystemSettings::body()   A

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\Integration\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 = $this->add(['View'])->addStyle('max-width:1200px;margin:auto;');
21
		$layout->add(['Header', __($this->label)]);
22
		$segment = $layout->add(['View', ['ui' => 'segment']]);
23
24
		$sections = [];
25
		/**
26
		 * @var SystemSettngsJoint $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
			$segment->add(['Header', $sectionName]);
36
			
37
			ksort($sectionJoints);
38
			
39
			foreach ($sectionJoints as $joint) {
40
				$segment->add($joint->button());
41
			}
42
		}
43
	}
44
}
45