Exemplo n.º 1
0
 /**
  * Returns a collection of the most recent Post  by the authenticating user and the users they follow
  * @return Response
  */
 public function home_timeline($id)
 {
     //get all follower where user id = follower_id
     $followers = Relationship::where('follower_id', $id)->get(array('following_id'));
     if ($followers->count() > 0) {
         $follower_id = array();
         array_push($follower_id, $id);
         foreach ($followers as $follower) {
             array_push($follower_id, $follower->following_id);
         }
         return Post::getPost($follower_id, $this->page, $this->per_page, $this->type);
     } else {
         return Response::json(array('status' => '0', 'message' => 'No user found'));
     }
 }
Exemplo n.º 2
0
 /**
  * Display friends from given user id.
  *
  * @param  int  $id
  * @return Response
  */
 public function friends_deprecated2($id)
 {
     $followings = Relationship::where('follower_id', $id)->where('following_id', '!=', $id)->where('active', '=', '1')->get(array('following_id'));
     $folllowings_id = array();
     foreach ($followings as $following) {
         array_push($folllowings_id, $following->following_id);
     }
     $accounts = Relationship::whereIn('following_id', $folllowings_id)->where('follower_id', '=', $id)->where('active', '=', '1')->take($this->per_page)->skip($this->ofset)->get();
     $total_account = Relationship::whereIn('following_id', $folllowings_id)->where('follower_id', '=', $id)->count();
     foreach ($accounts as $account) {
         $account->following_account->birthday;
         $account->following_account->gender;
         $account->following_account->avatar;
         $account->following_account->cover;
         $account->following_account->is_following = Helpers::SK_isFollowing($account->following_account->id, $id);
         array_push($this->users, $account->following_account);
     }
     $response = array('status' => '1', 'page' => $this->page, 'per_page' => $this->per_page, 'pages' => ceil(count($this->users) / $this->per_page), 'total' => count($this->users), 'users' => $this->users);
     return Response::json($response);
 }
Exemplo n.º 3
0
 public function scopeBlockRelationship($quest, $sender, $target)
 {
     //check if relationship already exists
     $results = DB::table('relationship')->select('*')->where('relationship_sender', '=', $target)->where('relationship_target', '=', $sender)->first();
     // if it's pending from someone requesting, then change to active
     if ($results) {
         Relationship::where('relationship_id', '=', $results->relationship_id)->update(array('relationship_status' => 'block'));
     }
     $relationship = new Relationship();
     $relationship->relationship_target = $target;
     $relationship->relationship_sender = $sender;
     $relationship->relationship_status = 'block';
     $relationship->save();
 }
 /**
  *   Función responsable de obtener el listado de parentescos civiles 
  *   disponibles para el país actual.
  *
  *   @return array, lista de parentescos civiles encontrados.
  */
 public function getRelationshipList($countryId = '')
 {
     if (empty($countryId)) {
         $countryId = Config::get('constants.APP.COUNTRY_CODES.CO');
     }
     $relationshipList = Relationship::where('countryId', $countryId)->orderBy(Config::get('constants.RELATIONSHIP.ATTRS.RELATIONSHIP_ID'))->get();
     return $relationshipList;
 }