当前位置: 首页>>代码示例>>PHP>>正文


PHP Conversation::where方法代码示例

本文整理汇总了PHP中Conversation::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Conversation::where方法的具体用法?PHP Conversation::where怎么用?PHP Conversation::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Conversation的用法示例。


在下文中一共展示了Conversation::where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showAll

 public function showAll()
 {
     $user = Confide::user();
     $conversations = Conversation::where('sender', '=', $user->id)->orWhere('receiver', '=', $user->id)->orderBy('created_at', 'desc')->get();
     foreach ($conversations as $conversation) {
         $conversation->sender = User::find($conversation->sender);
         $conversation->receiver = User::find($conversation->receiver);
     }
     return View::make('home/conversation/show-all', compact('user', 'conversations'));
 }
开发者ID:carlosqueiroz,项目名称:medical-management-system,代码行数:10,代码来源:ConversationController.php

示例2: store

 /**
  * Store a newly created message in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('body' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Response::json(['success' => false, 'result' => $validator->messages()]);
     }
     $conversation = Conversation::where('name', Input::get('conversation'))->first();
     $params = array('conversation_id' => $conversation->id, 'body' => Input::get('body'), 'user_id' => Input::get('user_id'), 'created_at' => new DateTime());
     $message = Message::create($params);
     // Create Message Notifications
     $messages_notifications = array();
     foreach ($conversation->users()->get() as $user) {
         array_push($messages_notifications, new MessageNotification(array('user_id' => $user->id, 'conversation_id' => $conversation->id, 'read' => false)));
     }
     $message->messages_notifications()->saveMany($messages_notifications);
     // Publish Data To Redis
     $data = array('room' => Input::get('conversation'), 'message' => array('body' => Str::words($message->body, 5), 'user_id' => Input::get('user_id')));
     Event::fire(ChatMessagesEventHandler::EVENT, array(json_encode($data)));
     return Response::json(['success' => true, 'result' => $message]);
 }
开发者ID:thantai574,项目名称:laravel-realtime-chat,代码行数:26,代码来源:MessageController.php

示例3: get_conversation

 public function get_conversation($conHash)
 {
     $ajaxRequest = false;
     $thread = false;
     $numbered = false;
     if (Request::ajax()) {
         $ajaxRequest = true;
     }
     $userid = Sentry::user()->id;
     /*There should be some protection about sniffing other messages*/
     /*Let check if this conversation exist*/
     $conThread = Conversation::where('id', '=', $conHash)->first();
     if (!$conThread) {
         return Redirect::to_action('messages@index');
     } elseif ($conThread->user_id != $userid && $conThread->receiver_id != $userid) {
         /*now we are looking if this conversation is ours*/
         return Redirect::to_action('messages@index');
     }
     $conversation = Message::with('author')->where('conversation_id', '=', $conHash)->order_by('date', 'asc')->get();
     if (!$ajaxRequest) {
         //This gets conversation that user started or we started..
         $conversation2 = Conversation::with('Author')->where('receiver_id', '=', Sentry::user()->id)->or_where(function ($query) {
             $query->where('user_id', '=', Sentry::user()->id);
         })->order_by('date', 'desc')->get();
         $view = View::make('messages.index');
         $view->cons = $conversation2;
         $view->ifgetverb = true;
         $view->title = "Mesajlar";
         $view->conversation = $conversation;
         $view->coninfo = $conThread;
         return $view;
     } else {
         $view = View::make('messages.ajaxrequest');
         $view->conversation = $conversation;
         $view->coninfo = $conThread;
         return $view;
     }
 }
开发者ID:TahsinGokalp,项目名称:L3-Sozluk,代码行数:38,代码来源:messages.php

示例4: addUserToConversation

 public function addUserToConversation()
 {
     $user = Auth::user();
     $input = Input::all();
     $conversationType = $input['type'];
     $conversationID = $input['conversationID'];
     $newConversationUsers = json_decode($input['userlist'], true);
     //check if a single conversation already exists
     if ($conversationType && $conversationType == 'single') {
         $otherUser = $newConversationUsers[0]['id'] == $user->id ? $newConversationUsers[1]['id'] : $newConversationUsers[0]['id'];
         $singleConversation = DB::select(DB::raw("select distinct *\n\t\t\t\tfrom conversation_user u\n\t\t\t\tjoin conversations c on c.id = u.conversation_id\n\t\t\t\twhere c.type = 'single' and (u.user_id = :currentUser or u.user_id = :otherUser)\n\t\t\t\tgroup by u.conversation_id\n\t\t\t\thaving count(u.conversation_id) = 2"), array('currentUser' => $user->id, 'otherUser' => $otherUser));
         if ($singleConversation) {
             return $singleConversation[0]->conversation_id;
         }
     }
     //create a new conversation if input doesn't have conversation id
     if (!$conversationID) {
         $conversation = new Conversation();
         $conversation->name = "Untitled Conversation";
         $conversation->lastest_message = "The room has been created !";
         $conversation->leader_id = $user['id'];
         $conversation->type = $conversationType;
         $conversation->save();
         $conversationID = $conversation->id;
     } else {
         Conversation::where('id', '=', $conversationID)->update(['type' => $conversationType]);
     }
     $currentConversationUsers = ConversationUser::where('conversation_id', '=', $conversationID)->get();
     foreach (json_decode($input['userlist']) as $key => $value) {
         # code...
         //print_r($value);
         $duplicateRecord = ConversationUser::where('user_id', '=', $value->id)->where('conversation_id', '=', $conversationID)->get();
         if (count($duplicateRecord) <= 0) {
             $conversationUser = new ConversationUser();
             $conversationUser->conversation_id = $conversationID;
             $conversationUser->user_id = $value->id;
             $conversationUser->save();
             // add user notification status
             $notificationStatus = new GroupNotificationStatus();
             $notificationStatus->conversation_id = $conversationID;
             $notificationStatus->user_id = $value->id;
             $notificationStatus->save();
         }
     }
     foreach ($currentConversationUsers as $key => $value) {
         $result = array_search(intval($value->user_id), array_column($newConversationUsers, 'id'));
         if (!$result && intval($value->user_id) != intval($user->id)) {
             ConversationUser::where('user_id', '=', $value->user_id)->where('conversation_id', '=', $conversationID)->delete();
         }
     }
     return $conversationID;
 }
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:52,代码来源:GroupMessageController.php

示例5: store

 public function store()
 {
     if (FEUsersHelper::isLogged()) {
         $current_user_id = Session::get('user')['id'];
         $r_user_id = Input::get('r_user_id');
         $conversations = Conversation::where(function ($query) use($current_user_id, $r_user_id) {
             $query->where('user1_id', '=', $current_user_id)->where('user2_id', '=', $r_user_id);
         })->orWhere(function ($query) use($current_user_id, $r_user_id) {
             $query->where('user1_id', '=', $r_user_id)->where('user2_id', '=', $current_user_id);
         })->orderBy('updated_at', 'DESC')->get();
         $message = new Message();
         if ($conversations->count() > 0) {
             $conversation = $conversations->first();
             $message->content = Input::get('content');
             $message->s_user_id = $current_user_id;
             $message->conversation_id = $conversation->id;
             $message->save();
             $conversation->updated_at = date('Y-m-d H:m:s');
             $conversation->save();
             return Redirect::to('message/' . $conversation->id);
         } else {
             $conversation = new Conversation();
             $conversation->user1_id = $current_user_id;
             $conversation->user2_id = Input::get('r_user_id');
             $conversation->save();
             $message->content = Input::get('content');
             $message->s_user_id = $current_user_id;
             $message->conversation_id = $conversation->id;
             $message->save();
             return Redirect::to('message/' . $conversation->id);
         }
     }
     return Redirect::to('/');
 }
开发者ID:huuson94,项目名称:WebProject,代码行数:34,代码来源:FEMessagesController.php

示例6: getByName

 public function getByName($name)
 {
     return $this->model->where('name', $name)->firstOrFail();
 }
开发者ID:thantai574,项目名称:laravel-realtime-chat,代码行数:4,代码来源:DbConversationRepository.php


注:本文中的Conversation::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。