|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: Mark |
|
5
|
|
|
* Date: 11/03/2016 |
|
6
|
|
|
* Time: 17:32. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace App\Modules\Settings; |
|
10
|
|
|
|
|
11
|
|
|
use App\Modules\ModuleEngine; |
|
12
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
13
|
|
|
use App\Classes\Repositories\SettingsRepository; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class Controller. |
|
17
|
|
|
*/ |
|
18
|
|
|
class Controller extends ModuleEngine |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var SettingsRepository |
|
22
|
|
|
*/ |
|
23
|
|
|
private $settings; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Controller constructor. |
|
27
|
|
|
* @param SettingsRepository $settings |
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct(SettingsRepository $settings) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->settings = $settings; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Settings are already loaded within the application |
|
36
|
|
|
* best to use the loaded settings from that instead. |
|
37
|
|
|
* |
|
38
|
|
|
* Helper function (Settings()) |
|
39
|
|
|
* |
|
40
|
|
|
* @return mixed |
|
41
|
|
|
*/ |
|
42
|
|
|
public function index() |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->make('index'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Save the changes for settings. |
|
49
|
|
|
* |
|
50
|
|
|
* @param Request $request |
|
51
|
|
|
* @return \Illuminate\Http\RedirectResponse |
|
52
|
|
|
*/ |
|
53
|
|
|
public function update(Request $request) |
|
54
|
|
|
{ |
|
55
|
|
|
if ($request['setting']['string']) { |
|
56
|
|
|
foreach ($request['setting']['string'] as $key => $value) { |
|
57
|
|
|
$this->settings->firstKey($key)->setValue($value)->save(); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
if ($request['setting']['boolean']) { |
|
62
|
|
|
foreach ($request['setting']['boolean'] as $key => $value) { |
|
63
|
|
|
$this->settings->firstKey($key)->setValue($value)->save(); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
if ($request['setting']['select']) { |
|
67
|
|
|
foreach ($request['setting']['select'] as $key => $value) { |
|
68
|
|
|
$this->settings->firstKey($key)->setValue($value)->save(); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
return redirect()->intended(route('admin.settings.index')); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|