Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- public function confirm(){
- $id = Input::get('service_id');
- $driver = Driver::find(Input::get('driver_id'));
- $servicio = Service::find($id);
- $response = $this->validate($servicio);
- if ($response !== true) {
- return $response;
- }
- Service::update($id,array('driver_id'=>$driver->id,'status_id','2','car_id'=>$driver->car_id));
- Driver::update($driver->id,array('available'=>'0'));
- $this->pushMessage($servicio);
- }
- public function validate($servicio){
- (!$servicio) ? $error = 3 : '';
- ($servicio->status_id == '6') ? $error = 2 : '';
- ($servicio->driver_id !== null) ? $error = 1 : '';
- ($servicio->status_id != '1') ? $error = 1: '';
- ($servicio->user->uuid == '') ? $error = 0 : '';
- if (!empty($error)) {
- return Response::json(array("error"=>$error));
- }
- return true;
- }
- public function pushMessage($servicio){
- $pushMessage =" Tu servicio ha sido confirmado";
- $push = Push::make();
- $iPhone = $this->isiPhone($servicio->user->type);
- if ($iPhone) {
- $push->ios($servicio->user->uuid,$pushMessage,1,$iPhone,'Open',array("serviceId"=>$servicio->id));
- }else{
- $push->android2($servicio->user->uuid,$pushMessage,1,"default",'Open',array("serviceId"=>$servicio->id));
- }
- }
- public function isiPhone($type){
- if ($type == 1) {
- return "honk.wav";
- }
- return false;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment