public function hogarPedidos()
 {
     $pedido = Pedidos::find(Input::get('idpedido'));
     $user = $usuario = User::where('id', '=', $pedido->id_usuario)->first();
     $restaurante = Restaurantes::where('id', '=', $pedido->id_restaurante);
     $var = Auth::user()->id_restaurante;
     $validacion = hd::where('id_restaurante', '=', $var)->get();
     if (Input::has('Confirmar')) {
         $pedido->estatus = 'sinPagar';
         $pedido->save();
         $envios = new Envios();
         $envios->estatus = 'pendiente';
         $envios->id_pedido = $pedido->id;
         $envios->coordenadas_accidente = 0;
         $envios->id_restaurante = $pedido->id_restaurante;
         $envios->save();
         foreach ($validacion as $key2 => $info2) {
             if ($info2->decision == 0) {
                 $reg = UsuariosHD::reg($var)->get();
                 if ($reg != "") {
                     foreach ($reg as $key => $info) {
                         $valor = PushNotification::Message('¡Envíos disponibles!', array('valor' => 1, 'sound' => 'example.aiff', 'actionLocKey' => 'Action button title!', 'locKey' => 'localized key', 'locArgs' => array('localized args', 'localized args'), 'launchImage' => 'image.jpg', 'custom' => array('custom data' => array('we' => 'want', 'send to app'))));
                         PushNotification::app('HappyDelivery')->to($info->reg_id)->send($valor);
                     }
                 }
             }
             if ($info2->decision == 1) {
                 $reg = UsuariosHD::reg2($var)->get();
                 if ($reg != "") {
                     foreach ($reg as $key => $info) {
                         $valor = PushNotification::Message('¡Envíos disponibles!', array('valor' => 1, 'sound' => 'example.aiff', 'actionLocKey' => 'Action button title!', 'locKey' => 'localized key', 'locArgs' => array('localized args', 'localized args'), 'launchImage' => 'image.jpg', 'custom' => array('custom data' => array('we' => 'want', 'send to app'))));
                         PushNotification::app('HappyDelivery')->to($info->reg_id)->send($valor);
                     }
                 }
             }
         }
         return Redirect::to('/')->with('success', 'Orden Aceptada Con Exito');
     } elseif (Input::has('Declinar')) {
         $pedido->estatus = 'declinada';
         $pedido->save();
         return Redirect::to('/')->with('success', 'Orden Cancelada Con Exito');
     }
 }
Пример #2
0
 public function EnviosDisC()
 {
     $usuarios = UsuariosHD::where('id', '=', Input::get('id'))->first();
     $usuarios1 = UsuariosHD::where('id_restaurante', '=', Input::get('id_restaurante'))->first();
     $pedido = Pedidos::All()->last();
     $pedidos = Pedidos::Envios()->get();
     foreach ($pedidos as $key2 => $value2) {
         $validacion = hd::where('id_restaurante', '=', $value2->id_restaurante)->get();
         $valor = 0;
         $envios = Envios::EnviosDis2($value2->id_restaurante)->get();
         foreach ($validacion as $key2 => $info2) {
             if ($info2->decision == 0) {
                 if ($usuarios->id_restaurante == $value2->id_restaurante or $usuarios->id_restaurante2 == $value2->id_restaurante) {
                     return Response::json($envios);
                 }
             }
             if ($info2->decision == 1) {
                 if ($usuarios->id_restaurante == $value2->id_restaurante or $usuarios->id_restaurante2 == $value2->id_restaurante or $usuarios->id_restaurante == 0 or $usuarios->id_restaurante2 == 0) {
                     return Response::json($envios);
                 }
             }
         }
     }
     return Response::json('ERROR GENERAL');
 }