コード例 #1
0
ファイル: Friendship.php プロジェクト: chirilo/Contentify
 /**
  * Query scope that returns the friendships of a user
  * 
  * @param  Builder  $query  The query builder object
  * @param  int      $userId The ID of the user
  * @param  boolean      $confirmed   Only show confirmed friendships? Default = true
  * @return Builder
  */
 public function scopeFriendsOf($query, $userId, $confirmed = true)
 {
     if ($confirmed) {
         $query->whereConfirmed(1);
     }
     return $query->where(function ($query) use($userId) {
         $query->whereSenderId($userId)->orWhere('receiver_id', $userId);
     });
 }