|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
|
6
|
|
|
|
|
7
|
|
|
use App\Http\Requests; |
|
8
|
|
|
use App\Http\Controllers\Controller; |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class SettingsController |
|
13
|
|
|
* @package App\Http\Controllers |
|
14
|
|
|
*/ |
|
15
|
|
|
class SettingsController extends Controller |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* SettingsController Constructor |
|
19
|
|
|
*/ |
|
20
|
|
|
public function __construct() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->middleware('auth'); |
|
23
|
|
|
$this->middleware('lang'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Display a listing of the resource. |
|
28
|
|
|
* |
|
29
|
|
|
* @return \Illuminate\Http\Response |
|
30
|
|
|
*/ |
|
31
|
|
|
public function basicView() |
|
32
|
|
|
{ |
|
33
|
|
|
|
|
34
|
|
|
$data['date_formats'] = array( |
|
|
|
|
|
|
35
|
|
|
'Y-m-d' => '2010-12-23', |
|
36
|
|
|
'm-d-Y' => '12-23-2010', |
|
37
|
|
|
'd-m-Y' => '23-12-2010', |
|
38
|
|
|
'Y/m/d' => '2010/12/23', |
|
39
|
|
|
'm/d/Y' => '12/23/2010', |
|
40
|
|
|
'd/m/Y' => '23/12/2010', |
|
41
|
|
|
'Y.m.d' => '2010.12.23', |
|
42
|
|
|
'd.m.Y' => '23.12.2010', |
|
43
|
|
|
'm.d.Y' => '12.23.2010', |
|
44
|
|
|
); |
|
45
|
|
|
|
|
46
|
|
|
$data['time_formats'] = array ( |
|
47
|
|
|
'H:i' => '23:00', |
|
48
|
|
|
'h:ia' => '11:00pm', |
|
49
|
|
|
'h:iA' => '11:00PM', |
|
50
|
|
|
'h:i a' => '11:00 pm', |
|
51
|
|
|
'h:i A' => '11:00 PM', |
|
52
|
|
|
); |
|
53
|
|
|
|
|
54
|
|
|
$data['title'] = config('timecontrol.title'); |
|
55
|
|
|
$data['email'] = config('timecontrol.email'); |
|
56
|
|
|
$data['date'] = config('timecontrol.date'); |
|
57
|
|
|
$data['time'] = config('timecontrol.time'); |
|
58
|
|
|
|
|
59
|
|
|
return view('settings/basic', $data); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Update the basic settings. |
|
64
|
|
|
* |
|
65
|
|
|
* @param \Illuminate\Http\Request $request |
|
66
|
|
|
* @return \Illuminate\Http\Response |
|
67
|
|
|
*/ |
|
68
|
|
|
public function generalUpdate(Request $request) |
|
69
|
|
|
{ |
|
70
|
|
|
|
|
71
|
|
|
$config = new \Larapack\ConfigWriter\Repository('timecontrol'); |
|
72
|
|
|
$config->set('title', $request->get('title')); |
|
73
|
|
|
$config->set('email', $request->get('email')); |
|
74
|
|
|
$config->set('date', $request->get('date')); |
|
75
|
|
|
$config->set('time', $request->get('time')); |
|
76
|
|
|
$config->save(); |
|
77
|
|
|
|
|
78
|
|
|
if ($config) { |
|
79
|
|
|
sleep(3); |
|
80
|
|
|
session()->flash('message', trans('FlashSession.settingSaveSuccess')); |
|
81
|
|
|
return redirect('settings/general'); |
|
82
|
|
|
} else { |
|
83
|
|
|
session()->flash('message', trans('FlashSession.settingSaveFailure')); |
|
84
|
|
|
return redirect('settings/general'); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Display a form to configure the backup settings. |
|
90
|
|
|
* |
|
91
|
|
|
* @return \Illuminate\Http\Response |
|
92
|
|
|
*/ |
|
93
|
|
|
public function backupView() |
|
94
|
|
|
{ |
|
95
|
|
|
$data['include'] = config('laravel-backup.backup.source.files.include'); |
|
|
|
|
|
|
96
|
|
|
$data['exclude'] = config('laravel-backup.backup.source.files.exclude'); |
|
97
|
|
|
|
|
98
|
|
|
$data['keepAllBackupsForDays'] = config('laravel-backup.cleanup.defaultStrategy.keepAllBackupsForDays'); |
|
99
|
|
|
|
|
100
|
|
|
return view('settings/backup', $data); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArrayis initialized the first time when the foreach loop is entered. You can also see that the value of thebarkey is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.