Example #1
0
 public static function InsertarNotificacionesMasivas($titulo, $mensaje, $excluidos = [])
 {
     $notificaciones = [];
     $usuarios = User::whereNotIn('id', $excluidos)->get();
     foreach ($usuarios as $usuario) {
         $notificaciones[] = ['titulo' => $titulo, 'mensaje' => $mensaje, 'user_id' => $usuario->id, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')];
     }
     Notificacion::insert($notificaciones);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $profesional = Profesional::leftJoin('especialidades', 'especialidades.id', '=', 'profesionales.especialidades_id')->leftJoin('sedes_profesionales', 'sedes_profesionales.profesional_id', '=', 'profesionales.id')->leftJoin('sedes', 'sedes.id', '=', 'sedes_profesionales.sede_id')->leftJoin('users', 'users.id', '=', 'profesionales.user_id')->groupBy('profesionales.id')->select('sedes.nombre', 'profesionales.id as p_id', 'profesionales.*', 'users.firstname as u_n', 'users.lastname as u_a', 'especialidades.*', DB::raw('GROUP_CONCAT(sedes.id) as sedes_pid'))->find($id);
     $sedes_pid = explode(',', $profesional->sedes_pid);
     $especialidades = Especialidad::lists('especialidad', 'id');
     $sedes = Sedes::get();
     $profesionales_cuser = Profesional::where('user_id', '!=', 0)->lists('user_id');
     $usuarios = User::whereNotIn('id', $profesionales_cuser)->get()->lists('fullname', 'id');
     $usuarios[0] = '-- Ninguno --';
     asort($usuarios);
     return View::make('profesionales.edit')->with('profesional', $profesional)->with('sedes', $sedes)->with('especialidades', $especialidades)->with(array('sedes_pid' => $sedes_pid, 'usuarios' => $usuarios));
 }
Example #3
0
 /**
  * Shows a message thread
  *
  * @param $id
  * @return mixed
  */
 public function show($id)
 {
     try {
         $thread = Thread::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.');
         return Redirect::to('messages');
     }
     // show current user in list if not a current participant
     // $users = User::whereNotIn('id', $thread->participantsUserIds())->get();
     // don't show the current user in list
     $userId = Auth::user()->id;
     $users = User::whereNotIn('id', $thread->participantsUserIds($userId))->get();
     $thread->markAsRead($userId);
     return View::make('messenger.show', compact('thread', 'users'));
 }
    public function show($id)
    {
        try{
$thread = Thread::findOrFail($id);
// отображения текущего пользователя в список, если не текущий участник 
        //$users = User::whereNotIn('id', $thread->participantsUserIds())->get();
// не показывать текущего пользователя в список 
        $userId = $this->user->id;
        $users = User::whereNotIn('id', $thread->participantsUserIds($userId))->get();

        $thread->markAsRead($userId);

        return View::make('messenger.show', compact('thread', 'users'));
}catch(Exception $e){
return Redirect::to()->withError('Темы с таким номером нет');
//$e->getMessage();
}

    }
 public function testIn()
 {
     $users = User::whereIn('age', array(13, 23))->get();
     $this->assertEquals(2, count($users));
     $users = User::whereIn('age', array(33, 35, 13))->get();
     $this->assertEquals(6, count($users));
     $users = User::whereNotIn('age', array(33, 35))->get();
     $this->assertEquals(4, count($users));
     $users = User::whereNotNull('age')->whereNotIn('age', array(33, 35))->get();
     $this->assertEquals(3, count($users));
 }
Example #6
0
 public static function getFeatureUsers()
 {
     $user_id = Session::get('user_id');
     $error_code = ApiResponse::OK;
     $users = User::whereNotIn('user_id', [$user_id])->orderBy(DB::raw("RAND()"))->with('profile')->take(10)->get();
     if ($users) {
         foreach ($users as $user) {
             if ($user->profile->image != null) {
                 $user->profile->image = URL::asset($user->profile->image);
             }
             $follow = Follow::where('from_id', $user_id)->where('to_id', $user->user_id)->first();
             if ($follow) {
                 $user->is_follow = true;
             } else {
                 $user->is_follow = false;
             }
         }
     }
     $data = $users->toArray();
     return array("code" => $error_code, "data" => $data);
 }
Example #7
0
 public function testIn()
 {
     $users = User::whereIn('age', [13, 23])->get();
     $this->assertEquals(2, count($users));
     $users = User::whereIn('age', [33, 35, 13])->get();
     $this->assertEquals(6, count($users));
     $users = User::whereNotIn('age', [33, 35])->get();
     $this->assertEquals(5, count($users));
     $users = User::whereNotNull('age')->whereNotIn('age', [33, 35])->get();
     $this->assertEquals(4, count($users));
 }