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

SystemSettings   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
c 0
b 0
f 0
dl 0
loc 32
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A body() 0 23 4
A access() 0 3 1
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