Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

erro Modulo 9 - Projeto Prático MVC (devsbook) - #33 - Amigos(2/2) #4

Open
sgtkievel opened this issue Jun 19, 2020 · 0 comments
Open

Comments

@sgtkievel
Copy link

ProfileController.php
`public function friends($atts = []){
$id = $this->loggedUser->id;
if(!empty($atts['id'])){
$id = $atts['id'];
}

    // Pegando informações do usuário
    $user = UserHandler::getUser($id, true);
    if(!$user){
        $this->redirect('/');
    }

    $dateFrom = new \DateTime($user->birthdate);
    $dateTo = new \DateTime('today');
    $user->ageYears = $dateFrom->diff($dateTo)->y;

    // Verificando se o usuário logado já está seguindo o usuário
    $isFollowing = false;
    if($user->id != $this->loggedUser->id){
        $isFollowing = UserHandler::isFollowing($this->loggedUser->id, $user->id);
    }

    $this->render('profile_friends', [
        'loggedUser' => $this->loggedUser,
        'user' => $user,
        'isFollowing' => $isFollowing
    ]);
}

==========================================================
profile_friends.php

                                <div class="full-friend-list">
                                    <?php foreach($user->followers as $follower): ?>
                                        <div class="friend-icon">
                                        <a href="<?=base;?>/perfil/<?=$follower->id; ?>">
                                            <div class="friend-icon-avatar">
                                                <img src="<?=$base;?>/media/avatars/<?=$follower->avatar;?>" />
                                            </div>
                                            <div class="friend-icon-name">
                                                <?=$follower->name;?>
                                            </div>
                                        </a>
                                    </div>
                                    <?php endforeach; ?>    
                                </div>

                            </div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant