115 | | DB::table('rezervacii')->insert([ |
116 | | 'idkorisnik' => auth()->id(), |
117 | | 'idaktivnost' => $request->aktivnost_id, |
118 | | 'datum' => now() |
119 | | ]); |
120 | | |
121 | | DB::table('aktivnosti') |
122 | | ->where('idaktivnost', $request->aktivnost_id) |
123 | | ->decrement('kvota', 1); |
| 115 | DB::table('activity_reservation')->insert([ |
| 116 | 'id_user' => auth()->id(), |
| 117 | 'id_activity' => $request->activity_id, |
| 118 | 'reservation_date' => now() |
| 119 | ]); |
| 120 | |
| 121 | DB::table('activity') |
| 122 | ->where('id_activity', $request->activity_id) |
| 123 | ->decrement('amount', 1); |
131 | | DB::transaction(function () use ($request) { |
132 | | $validatedData = $request->validate([ |
133 | | 'imepaket' => 'required|string|max:255', |
134 | | 'cena' => 'required|numeric', |
135 | | 'pochetok' => 'required|date_format:Y-m-d\TH:i', |
136 | | 'kraj' => 'required|date_format:Y-m-d\TH:i|after_or_equal:pochetok', |
137 | | ]); |
138 | | |
139 | | TravelPackage::create($validatedData); |
140 | | }); |
| 131 | // Внесување TravelPackage |
| 132 | DB::transaction(function () use ($request) { |
| 133 | $validatedData = $request->validate([ |
| 134 | 'package_name' => 'required|string|max:255', |
| 135 | 'price' => 'required|numeric', |
| 136 | 'start_date' => 'required|date_format:Y-m-d\TH:i', |
| 137 | 'end_date' => 'required|date_format:Y-m-d\TH:i|after_or_equal:start_date', |
| 138 | 'id_destination' => 'required|integer|exists:destination,id_destination' |
| 139 | ]); |
| 140 | |
| 141 | TravelPackage::create($validatedData); |
| 142 | }); |
145 | | DB::transaction(function () use ($request) { |
146 | | $validatedData = $request->validate([ |
147 | | 'naziv' => 'required|string|max:255', |
148 | | 'vidovi' => 'required|string|max:255', |
149 | | 'detali' => 'nullable|string', |
150 | | 'pochetendatum' => 'required|date', |
151 | | 'kraendatum' => 'required|date', |
152 | | ]); |
153 | | |
154 | | TravelEvent::create($validatedData); |
155 | | }); |
156 | | }}} |
157 | | |
158 | | |
159 | | {{{ |
160 | | DB::transaction(function () use ($request) { |
161 | | $validatedData = $request->validate([ |
162 | | 'imeaktivnost' => 'required|string|max:255', |
163 | | 'informacii' => 'nullable|string|max:255', |
164 | | 'kategorija' => 'required|string|max:255', |
165 | | 'iznos' => 'nullable|numeric', |
166 | | ]); |
167 | | |
168 | | TravelActivity::create($validatedData); |
169 | | }); |
| 147 | // Внесување TravelEvent |
| 148 | DB::transaction(function () use ($request) { |
| 149 | $validatedData = $request->validate([ |
| 150 | 'event_name' => 'required|string|max:255', |
| 151 | 'event_type' => 'required|string|max:255', |
| 152 | 'details' => 'nullable|string', |
| 153 | 'start_date' => 'required|date', |
| 154 | 'end_date' => 'required|date', |
| 155 | 'id_destination' => 'required|integer|exists:destination,id_destination' |
| 156 | ]); |
| 157 | |
| 158 | TravelEvent::create($validatedData); |
| 159 | }); |
| 160 | }}} |
| 161 | |
| 162 | |
| 163 | {{{ |
| 164 | // Внесување TravelActivity |
| 165 | DB::transaction(function () use ($request) { |
| 166 | $validatedData = $request->validate([ |
| 167 | 'activity_name' => 'required|string|max:255', |
| 168 | 'information' => 'nullable|string|max:255', |
| 169 | 'category' => 'required|string|max:255', |
| 170 | 'amount' => 'nullable|numeric', |
| 171 | 'id_destination' => 'required|integer|exists:destination,id_destination' |
| 172 | ]); |
| 173 | |
| 174 | TravelActivity::create($validatedData); |
| 175 | }); |