-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodigoPHP.php
43 lines (40 loc) · 1.24 KB
/
CodigoPHP.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
public function post_confirm() {
$driverId = Input::get('driver_id');
$servicioId = Input::get('service_id');
$servicio = Service::find($servicioId);
$error = '0';
if($servicio != NULL) {
if($servicio->status_id == '6') {
$error = '2';
}
else if($servicio->driver_id == NULL && $servicio->status_id == '1') {
$servicio = Service::update($servicioId, array(
'driver_id' => $driverId,
'status_id' => '2'
));
Driver::update($driverId, array(
"available" => '0'
));
$driverTmp = Driver::find($driverId);
Service::update($servicioId, array(
'car_id' => $driverTmp->car_id
));
// Notifica al usuario
$pushMessage = 'Tu servicio ha sido confirmado!';
$servicio = Service::find($servicioId);
$pushMessage = Push::make();
if($servicio->user->uuid != '') {
if($servicio->user->type == '1') { // iPhone
$result = $push->ios($servicio->user->uuid, $pushMessage, 1, 'honk.wav', 'Open', array('serviceId' => servicio->id));
} else { // android
$result = $push->android2($servicio->user->uuid, $pushMessage, 1, 'default', 'Open', array('serviceId' => servicio->id));
}
}
} else {
$error = '1';
}
} else {
$error = '3';
}
return Response::json(array('error' => $error));
}