|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Requests\InitialStateRequest; |
|
6
|
|
|
use Illuminate\Support\Facades\App; |
|
7
|
|
|
use Illuminate\Support\Facades\DB; |
|
8
|
|
|
|
|
9
|
|
|
class AdminController extends Controller |
|
10
|
|
|
{ |
|
11
|
3 |
|
public function getRouteName() |
|
12
|
|
|
{ |
|
13
|
3 |
|
return 'admin'; |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
3 |
|
public function index() |
|
17
|
|
|
{ |
|
18
|
3 |
|
$title = trans('general.administration_panel'); |
|
19
|
|
|
|
|
20
|
|
|
$viewData = [ |
|
21
|
3 |
|
'routeName' => $this->getRouteName(), |
|
22
|
3 |
|
'title' => $title, |
|
23
|
|
|
]; |
|
24
|
|
|
|
|
25
|
3 |
|
return view('admin', $viewData); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
2 |
|
public function showInitialStateForm() |
|
29
|
|
|
{ |
|
30
|
2 |
|
$title = trans('navigation.generate_initial_state'); |
|
31
|
|
|
|
|
32
|
2 |
|
$fiels = $this->getInitialStateFields(); |
|
33
|
|
|
|
|
34
|
|
|
$viewData = [ |
|
35
|
2 |
|
'dataset' => null, |
|
36
|
2 |
|
'fields' => $fiels, |
|
37
|
2 |
|
'title' => $title, |
|
38
|
2 |
|
'submitRoute' => route($this->getRouteName().'.postgenerate'), |
|
39
|
2 |
|
'routeName' => $this->getRouteName(), |
|
40
|
|
|
]; |
|
41
|
|
|
|
|
42
|
2 |
|
return view('addedit', $viewData); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
2 |
|
public function postInitialState(InitialStateRequest $request) |
|
46
|
|
|
{ |
|
47
|
2 |
|
factory(\App\Models\Room::class, (int) $request->input('rooms'))->create(); |
|
48
|
|
|
|
|
49
|
2 |
|
if (App::isLocale('pl')) { |
|
50
|
1 |
|
factory(\App\Models\Guest::class, (int) $request->input('guests'))->states('polish')->create(); |
|
51
|
|
|
} else { |
|
52
|
1 |
|
factory(\App\Models\Guest::class, (int) $request->input('guests'))->create(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
2 |
|
return redirect()->route($this->getRouteName().'.index') |
|
56
|
2 |
|
->with([ |
|
57
|
2 |
|
'message' => trans('general.saved'), |
|
58
|
2 |
|
'alert-class' => 'alert-success', |
|
59
|
|
|
]); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
1 |
|
public function deleteAllRooms() |
|
63
|
|
|
{ |
|
64
|
1 |
|
DB::table('reservations')->delete(); |
|
65
|
1 |
|
DB::table('rooms')->delete(); |
|
66
|
|
|
|
|
67
|
1 |
|
$data = ['class' => 'alert-success', 'message' => trans('general.deleted')]; |
|
68
|
|
|
|
|
69
|
1 |
|
return response()->json($data); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
1 |
|
public function deleteAllGuests() |
|
73
|
|
|
{ |
|
74
|
1 |
|
DB::table('reservations')->delete(); |
|
75
|
1 |
|
DB::table('guests')->delete(); |
|
76
|
|
|
|
|
77
|
1 |
|
$data = ['class' => 'alert-success', 'message' => trans('general.deleted')]; |
|
78
|
|
|
|
|
79
|
1 |
|
return response()->json($data); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
1 |
|
public function deleteAllReservations() |
|
83
|
|
|
{ |
|
84
|
1 |
|
DB::table('reservations')->delete(); |
|
85
|
|
|
|
|
86
|
1 |
|
$data = ['class' => 'alert-success', 'message' => trans('general.deleted')]; |
|
87
|
|
|
|
|
88
|
1 |
|
return response()->json($data); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
2 |
|
public function getInitialStateFields() |
|
92
|
|
|
{ |
|
93
|
|
|
return [ |
|
94
|
|
|
[ |
|
95
|
2 |
|
'id' => 'rooms', |
|
96
|
2 |
|
'title' => trans('general.rooms'), |
|
97
|
2 |
|
'value' => function () { |
|
98
|
2 |
|
return 1; |
|
99
|
2 |
|
}, |
|
100
|
2 |
|
'type' => 'number', |
|
101
|
|
|
'optional' => [ |
|
102
|
|
|
'required' => 'required', |
|
103
|
|
|
'min' => '1', |
|
104
|
|
|
], |
|
105
|
|
|
], |
|
106
|
|
|
[ |
|
107
|
2 |
|
'id' => 'guests', |
|
108
|
2 |
|
'title' => trans('general.guests'), |
|
109
|
2 |
|
'value' => function () { |
|
110
|
2 |
|
return 1; |
|
111
|
2 |
|
}, |
|
112
|
2 |
|
'type' => 'number', |
|
113
|
|
|
'optional' => [ |
|
114
|
|
|
'required' => 'required', |
|
115
|
|
|
'min' => '1', |
|
116
|
|
|
], |
|
117
|
|
|
], |
|
118
|
|
|
]; |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|