|
@@ -87,7 +87,7 @@ class TransportationController extends Controller
|
87
|
87
|
return $this->resSuccess(null, $res_status, $msg, $status_msg, null);
|
88
|
88
|
}
|
89
|
89
|
}
|
90
|
|
-
|
|
90
|
+
|
91
|
91
|
public function postStore(Request $request)
|
92
|
92
|
{
|
93
|
93
|
$post = $request->all();
|
|
@@ -96,6 +96,7 @@ class TransportationController extends Controller
|
96
|
96
|
/**digunakan untuk set rule validator */
|
97
|
97
|
$rules = [
|
98
|
98
|
'gambar' => 'required',
|
|
99
|
+ 'user_id' => 'required',
|
99
|
100
|
// 'gambar' => 'required|file|max:1000',
|
100
|
101
|
];
|
101
|
102
|
/**digunakan untuk set message dari validatornya yang akan keluar gimna, :attribue itu udah langsung mendeteksi inputtan dari name="attribue" */
|
|
@@ -121,8 +122,13 @@ class TransportationController extends Controller
|
121
|
122
|
$query->transportation_identity = $request->transportation_identity;
|
122
|
123
|
$query->transportation_type = $request->transportation_type;
|
123
|
124
|
$query->transportation_photo = Helper::base64_to_image($request->gambar, 'transportation');
|
124
|
|
- $query->user_id = 123456;
|
|
125
|
+ $query->user_id = Helper::hash(Request::all()['user_id'], 'decode');
|
125
|
126
|
$query->save();
|
|
127
|
+
|
|
128
|
+ $query->hash_id = Helper::hash($query->id, 'encode');
|
|
129
|
+ $query->user_id = Helper::hash($query->user_id, 'encode');
|
|
130
|
+
|
|
131
|
+
|
126
|
132
|
if($query){
|
127
|
133
|
$result = $query;
|
128
|
134
|
|
|
@@ -143,6 +149,99 @@ class TransportationController extends Controller
|
143
|
149
|
}
|
144
|
150
|
}
|
145
|
151
|
|
|
152
|
+ public function postUpdate(Request $request)
|
|
153
|
+ {
|
|
154
|
+ $post = $request->all();
|
|
155
|
+
|
|
156
|
+ $rules = [
|
|
157
|
+ 'id' => 'required',
|
|
158
|
+ 'gambar' => 'required',
|
|
159
|
+ 'user_id' => 'required',
|
|
160
|
+ ];
|
|
161
|
+
|
|
162
|
+ $validator = Validator::make($post, $rules);
|
|
163
|
+
|
|
164
|
+ if(!$validator->fails()){
|
|
165
|
+ $transportation = Transportation::where('id', Helper::hash(Request::all()['id'], 'decode'))->firstOrFail();
|
|
166
|
+
|
|
167
|
+ $transportation->name = $request->name;
|
|
168
|
+ $transportation->transportation_identity = $request->transportation_identity;
|
|
169
|
+ $transportation->transportation_type = $request->transportation_type;
|
|
170
|
+ $transportation->transportation_photo = Helper::base64_to_image($request->gambar, 'transportation');
|
|
171
|
+ $transportation->user_id = Helper::hash(Request::all()['user_id'], 'decode');
|
|
172
|
+ $transportation->save();
|
|
173
|
+
|
|
174
|
+ $transportation->hash_id = Helper::hash($transportation->id, 'encode');
|
|
175
|
+ $transportation->user_id = Helper::hash($transportation->user_id, 'encode');
|
|
176
|
+
|
|
177
|
+ $result = $transportation;
|
|
178
|
+ $res_status = true;
|
|
179
|
+ $msg = 'Berhasil membuat user';
|
|
180
|
+ $status_msg = $msg;
|
|
181
|
+
|
|
182
|
+ return $this->resSuccess(null, $res_status, $msg, $status_msg, $result);
|
|
183
|
+
|
|
184
|
+ }else {
|
|
185
|
+
|
|
186
|
+ $res_status = false;
|
|
187
|
+ $msg = 'Gagal Membuat user';
|
|
188
|
+ $status_msg = $validator->errors();
|
|
189
|
+
|
|
190
|
+ return $this->resSuccess(null, $res_status, $msg, $status_msg, null);
|
|
191
|
+ }
|
|
192
|
+ }
|
|
193
|
+
|
|
194
|
+ public function delete()
|
|
195
|
+ {
|
|
196
|
+ $validator = Validator::make(Request::all(), [
|
|
197
|
+ 'id' => ['required'],
|
|
198
|
+ ]);
|
|
199
|
+ if(!$validator->fails()){
|
|
200
|
+ $query = Transportation::find(Helper::hash(Request::all()['id'], 'decode'))->detroy();
|
|
201
|
+
|
|
202
|
+ if($query){
|
|
203
|
+ $result = $query;
|
|
204
|
+ $res_status = true;
|
|
205
|
+ $msg = 'Data berhasil dihapus';
|
|
206
|
+ $status_msg = $msg;
|
|
207
|
+
|
|
208
|
+ return $this->resSuccess(null, $res_status, $msg, $status_msg, $result);
|
|
209
|
+ }else{
|
|
210
|
+ $result = $query;
|
|
211
|
+ $res_status = false;
|
|
212
|
+ $msg = 'Data gagal dihapus';
|
|
213
|
+ $status_msg = $msg;
|
|
214
|
+
|
|
215
|
+ return $this->resSuccess(null, $res_status, $msg, $status_msg, $result);
|
|
216
|
+ }
|
|
217
|
+ }else{
|
|
218
|
+ $res_status = false;
|
|
219
|
+ $msg = 'Data tidak ditemukan';
|
|
220
|
+ $status_msg = $validator->errors();
|
|
221
|
+
|
|
222
|
+ return $this->resSuccess(null, $res_status, $msg, $status_msg, null);
|
|
223
|
+ }
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+ if($query){
|
|
227
|
+ $result = $query;
|
|
228
|
+
|
|
229
|
+ $res_status = true;
|
|
230
|
+ $msg = 'Mendapatkan Data';
|
|
231
|
+ $status_msg = $msg;
|
|
232
|
+
|
|
233
|
+ return $this->resSuccess(null, $res_status, $msg, $status_msg, $result);
|
|
234
|
+
|
|
235
|
+ }else {
|
|
236
|
+
|
|
237
|
+ $res_status = false;
|
|
238
|
+ $msg = 'Data tidak ditemukan';
|
|
239
|
+ $status_msg = $msg;
|
|
240
|
+
|
|
241
|
+ return $this->resSuccess(null, $res_status, $msg, $status_msg, null);
|
|
242
|
+ }
|
|
243
|
+ }
|
|
244
|
+
|
146
|
245
|
public function resSuccess($param = null, $status = null, $msg = null, $status_msg = null, $result = null)
|
147
|
246
|
{
|
148
|
247
|
$response['response'] = array(
|