Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. foreach($self_conversations as $self_conversations_fetch){
  2. //fetching each conversation id
  3. $conversation_id = Conversation::find($self_conversations_fetch->conversation_id);
  4. $user_id = array();
  5.  
  6. //fetching each conversation member's id
  7. foreach($conversation_id->conversationsMember as $conversationmembers)
  8. $user_id[] = $conversationmembers->user_id;
  9.  
  10. $self_id = User::where('email', Session::get('email'))->first()->id;
  11. $self_id_array = array($self_id);
  12. $friend_id_array = array_diff($user_id, $self_id_array);
  13.  
  14. foreach($friend_id_array as $friend_id) array_push($friend_ids, $friend_id);
  15.  
  16. $conversations_reply_obj = ConversationReply::where('conversation_id', $self_conversations_fetch->conversation_id)->orderBy('updated_at', 'desc')->first();
  17.  
  18. $conversations_reply[] = $conversations_reply_obj['reply'];
  19. }
  20.  
  21. $conversations_reply[] = $conversations_reply_obj['reply'];
  22.  
  23. $users = User::all(); // returns a collection
  24.  
  25. $users = User::all();
  26. $users->first();
  27.  
  28. $user = User::first();
  29.  
  30. $users = User::all();
  31. $users = User::get(0) // to get first item/model
  32. $users = User::get(1) // to get second item/model
  33.  
  34. $users = User::get(); // same as all
  35. // pass the collection to the view
  36. return View::make('users.index')->with('users', $users);
  37.  
  38. @foreach($users as $user)
  39. {{ $user->username }}<br />
  40. {{ $user->email }}<br />
  41. @endforeach
  42.  
  43. $user = user::find(1); // 1 is id for example
  44. return View::make('users.index')->with('user', $user);
  45.  
  46. $user = User::where('username', 'me')->get();
  47. return View::make('users.index')->with('user', $user);
  48.  
  49. {{ $user->name }}
  50. {{ $user['name'] }}
  51.  
  52. $student->school->school_name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement