<?php if($item->username == $this->session->username) : ?>
<!-- If friendship accepted - You can cancel the friendship request to this user -->
<?php elseif($relationship->status == 'accepted') : ?>
<?= form_open('users/unfollow/'.$item->id.'/'.$item->username) ; ?>
<?php $data = array(
'name' => 'friend_id',
'id' => 'friend_id',
'value' => $item->id,
); ?>
<?= form_hidden($data); ?>
<?= form_submit('mysubmit', 'Unfollow', array('class' => 'btn btn-warning btn-xs')); ?>
<?= form_close(); ?>
<!-- If friendship pending - You can cancel the friendship request to this user -->
<?php elseif($relationship->status == 'pending') : ?>
<?= form_open('users/unfollow/'.$item->id.'/'.$item->username) ; ?>
<?php $data = array(
'name' => 'friend_id',
'id' => 'friend_id',
'value' => $item->id,
); ?>
<?= form_hidden($data); ?>
<?= form_submit('mysubmit', 'Pending - Cancel Friend Request', array('class' => 'btn btn-warning btn-xs')); ?>
<?= form_close(); ?>
<!-- If no friendship exists whatsoever - You can send a friendship request to this user -->
<?php else : ?>
<?= form_open('users/follow/'.$item->username) ; ?>
<?php $data = array(
'name' => 'friend_id',
'id' => 'friend_id',
'value' => set_value('friend_id'),
); ?>
<?= form_hidden($data); ?>
<?= form_submit('mysubmit', 'Follow', array('class' => 'btn btn-warning btn-xs')); ?>
<?= form_close(); ?>
<?php endif; ?>