本文整理匯總了PHP中App\Repositories\UserRepository::acceptFriendRequest方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserRepository::acceptFriendRequest方法的具體用法?PHP UserRepository::acceptFriendRequest怎麽用?PHP UserRepository::acceptFriendRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類App\Repositories\UserRepository
的用法示例。
在下文中一共展示了UserRepository::acceptFriendRequest方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postAcceptFriendRequest
/**
* Accept a friend request
*
* @return string
*/
public function postAcceptFriendRequest()
{
try {
//User must be logged in
if (!$this->auth->check()) {
//Notify error
$this->keeper->put('notificationError', 'You must log in to continue');
//Return to login
redirect('/login', 'location');
}
//Set validation rules
$this->form_validation->set_rules('user_id', 'User identifier', 'required|xss_clean');
//Validation fails
if ($this->form_validation->run() === false) {
//Raise exception
throw new Exception('User identifier missing', 422);
}
//Perform accept friend request
$results = $this->userRepo->acceptFriendRequest($this->auth->user(), $this->userRepo->findUser($this->input->post('user_id')));
//Return results
echo json_encode(['error' => !$results]);
} catch (Exception $e) {
//Unexpected error
echo json_encode(['error' => true, 'message' => $e->getMessage()]);
}
}